mirror of
https://github.com/plexguide/Huntarr.io.git
synced 2026-01-06 06:00:08 -06:00
932 lines
39 KiB
HTML
932 lines
39 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Setup - Huntarr</title>
|
|
<!-- Inline script to prevent theme flashing -->
|
|
<script>
|
|
// Always use dark mode for setup page
|
|
document.documentElement.classList.add('dark-theme');
|
|
document.write('<style>body, html { background-color: #1a1d24 !important; color: #f8f9fa !important; } .login-container { background-color: #252a34 !important; } .login-header { background-color: #121212 !important; }</style>');
|
|
</script>
|
|
<!-- Preload logo -->
|
|
<link rel="preload" href="./static/logo/256.png" as="image" fetchpriority="high">
|
|
<link rel="stylesheet" href="./static/css/style.css">
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
|
<style>
|
|
/* Match the heart icon pulsing animation from the sidebar */
|
|
@keyframes heart-pulse {
|
|
0% { color: #ff4d6d; text-shadow: 0 0 10px #ff4d6d, 0 0 20px #ff4d6d; } /* Pink */
|
|
50% { color: #ff0a33; text-shadow: 0 0 15px #ff0a33, 0 0 25px #ff0a33; } /* Red */
|
|
100% { color: #ff4d6d; text-shadow: 0 0 10px #ff4d6d, 0 0 20px #ff4d6d; } /* Pink */
|
|
}
|
|
|
|
/* Heart animation scaling effect */
|
|
@keyframes pulse-heart {
|
|
0% {
|
|
transform: scale(1);
|
|
opacity: 0.7;
|
|
}
|
|
100% {
|
|
transform: scale(1.2);
|
|
opacity: 1;
|
|
}
|
|
}
|
|
|
|
/* Special thankyou heart styling */
|
|
.thankyou-heart {
|
|
animation: heart-pulse 7.2s infinite ease-in-out, pulse-heart 1.5s infinite alternate;
|
|
font-size: 28px;
|
|
}
|
|
|
|
/* Define logo glowing animation same as sidebar */
|
|
@keyframes logo-glow {
|
|
0% { box-shadow: 0 0 15px #3498db, 0 0 5px rgba(52, 152, 219, 0.4); } /* Sonarr blue */
|
|
20% { box-shadow: 0 0 15px #f1c40f, 0 0 5px rgba(241, 196, 15, 0.4); } /* Radarr yellow */
|
|
40% { box-shadow: 0 0 15px #2ecc71, 0 0 5px rgba(46, 204, 113, 0.4); } /* Lidarr green */
|
|
60% { box-shadow: 0 0 15px #e74c3c, 0 0 5px rgba(231, 76, 60, 0.4); } /* Readarr red */
|
|
80% { box-shadow: 0 0 15px #9b59b6, 0 0 5px rgba(155, 89, 182, 0.4); } /* Whisparr purple */
|
|
100% { box-shadow: 0 0 15px #3498db, 0 0 5px rgba(52, 152, 219, 0.4); } /* Back to Sonarr blue */
|
|
}
|
|
|
|
/* Logo styling */
|
|
.huntarr-logo {
|
|
width: 60px;
|
|
height: 60px;
|
|
border-radius: 50%;
|
|
animation: logo-glow 10s infinite ease-in-out;
|
|
transition: all 0.3s ease;
|
|
margin-bottom: 5px;
|
|
}
|
|
</style>
|
|
<link rel="icon" href="./static/logo/16.png">
|
|
<!-- Preload script to prevent flashing -->
|
|
<script src="./static/js/theme-preload.js"></script>
|
|
<style>
|
|
/* Modern setup page styles */
|
|
.login-page {
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
min-height: 100vh;
|
|
background: linear-gradient(135deg, #13171f 0%, #1c2230 100%);
|
|
margin: 0;
|
|
padding: 20px;
|
|
}
|
|
|
|
.login-container {
|
|
width: 625px; /* Increased by 25% */
|
|
max-width: 90%;
|
|
background: linear-gradient(180deg, rgba(22, 26, 34, 0.98), rgba(18, 22, 30, 0.95));
|
|
border-radius: 15px;
|
|
box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
|
|
overflow: hidden;
|
|
border: 1px solid rgba(90, 109, 137, 0.15);
|
|
}
|
|
|
|
.login-header {
|
|
background: linear-gradient(180deg, rgba(18, 22, 30, 0.98), rgba(24, 28, 37, 0.95));
|
|
padding: 25px 0;
|
|
text-align: center;
|
|
border-bottom: 1px solid rgba(90, 109, 137, 0.15);
|
|
}
|
|
|
|
.login-logo {
|
|
width: 70px;
|
|
height: 70px;
|
|
margin-bottom: 10px;
|
|
filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.2));
|
|
transition: transform 0.3s ease;
|
|
opacity: 1;
|
|
}
|
|
|
|
.login-logo:hover {
|
|
transform: scale(1.05);
|
|
}
|
|
|
|
.login-header h1 {
|
|
margin: 0;
|
|
color: #fff;
|
|
font-size: 24px;
|
|
font-weight: 600;
|
|
text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
|
|
}
|
|
|
|
.login-form {
|
|
padding: 25px;
|
|
}
|
|
|
|
/* Setup steps navigation */
|
|
.setup-steps {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
margin-bottom: 20px;
|
|
gap: 10px;
|
|
}
|
|
|
|
.step {
|
|
padding: 10px;
|
|
background: rgba(28, 36, 54, 0.6);
|
|
border-radius: 10px;
|
|
font-weight: 500;
|
|
flex: 1;
|
|
text-align: center;
|
|
margin: 0;
|
|
opacity: 0.6;
|
|
font-size: 0.85em;
|
|
transition: all 0.3s ease;
|
|
border: 1px solid rgba(90, 109, 137, 0.2);
|
|
color: rgba(255, 255, 255, 0.7);
|
|
}
|
|
|
|
.step.active {
|
|
background: linear-gradient(135deg, #3a71e4 0%, #5481e6 100%);
|
|
color: white;
|
|
opacity: 1;
|
|
border-color: rgba(90, 109, 137, 0.3);
|
|
box-shadow: 0 4px 10px rgba(58, 113, 228, 0.2);
|
|
transform: translateY(-2px);
|
|
}
|
|
|
|
.step.completed {
|
|
background: linear-gradient(135deg, #28a745 0%, #34ce57 100%);
|
|
color: white;
|
|
opacity: 1;
|
|
border-color: rgba(40, 167, 69, 0.3);
|
|
}
|
|
|
|
/* Form styling */
|
|
.setup-section {
|
|
display: none;
|
|
animation: fadeIn 0.3s ease;
|
|
}
|
|
|
|
.setup-section.active {
|
|
display: block;
|
|
}
|
|
|
|
@keyframes fadeIn {
|
|
from { opacity: 0; transform: translateY(5px); }
|
|
to { opacity: 1; transform: translateY(0); }
|
|
}
|
|
|
|
.form-group {
|
|
margin-bottom: 20px;
|
|
position: relative;
|
|
}
|
|
|
|
.form-group label {
|
|
display: flex;
|
|
align-items: center;
|
|
margin-bottom: 8px;
|
|
color: rgba(255, 255, 255, 0.9);
|
|
font-weight: 500;
|
|
}
|
|
|
|
.form-group label i {
|
|
margin-right: 8px;
|
|
color: rgba(65, 105, 225, 0.9);
|
|
}
|
|
|
|
.form-group input {
|
|
width: 100%;
|
|
padding: 12px 15px;
|
|
border: 1px solid rgba(90, 109, 137, 0.2);
|
|
border-radius: 8px;
|
|
background-color: rgba(28, 36, 54, 0.6);
|
|
color: #fff;
|
|
font-size: 16px;
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.form-group input:focus {
|
|
border-color: rgba(65, 105, 225, 0.6);
|
|
box-shadow: 0 0 0 3px rgba(65, 105, 225, 0.2);
|
|
outline: none;
|
|
}
|
|
|
|
.password-requirements {
|
|
margin-top: 8px;
|
|
font-size: 13px;
|
|
color: rgba(255, 255, 255, 0.7);
|
|
}
|
|
|
|
.requirement {
|
|
display: flex;
|
|
align-items: center;
|
|
margin-bottom: 3px;
|
|
}
|
|
|
|
.requirement i {
|
|
margin-right: 5px;
|
|
font-size: 12px;
|
|
}
|
|
|
|
.requirement.valid i {
|
|
color: #28a745;
|
|
}
|
|
|
|
.requirement.invalid i {
|
|
color: #dc3545;
|
|
}
|
|
|
|
.toggle-password {
|
|
position: absolute;
|
|
right: 12px;
|
|
top: 40px;
|
|
cursor: pointer;
|
|
color: rgba(255, 255, 255, 0.6);
|
|
}
|
|
|
|
.toggle-password:hover {
|
|
color: rgba(255, 255, 255, 0.9);
|
|
}
|
|
|
|
/* Buttons and actions */
|
|
.form-actions {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
margin-top: 25px;
|
|
}
|
|
|
|
.next-button, .back-button, .submit-button {
|
|
padding: 12px 24px;
|
|
border-radius: 8px;
|
|
font-weight: 600;
|
|
font-size: 16px;
|
|
transition: all 0.3s ease;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
}
|
|
|
|
.next-button, .submit-button {
|
|
background: linear-gradient(135deg, #3a71e4 0%, #5481e6 100%);
|
|
color: white;
|
|
border: none;
|
|
box-shadow: 0 4px 10px rgba(58, 113, 228, 0.3);
|
|
}
|
|
|
|
.next-button:hover, .submit-button:hover {
|
|
background: linear-gradient(135deg, #4a7deb 0%, #6491fa 100%);
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 6px 15px rgba(58, 113, 228, 0.4);
|
|
}
|
|
|
|
.back-button {
|
|
background: transparent;
|
|
border: 1px solid rgba(90, 109, 137, 0.3);
|
|
color: rgba(255, 255, 255, 0.8);
|
|
}
|
|
|
|
.back-button:hover {
|
|
background: rgba(90, 109, 137, 0.1);
|
|
border-color: rgba(90, 109, 137, 0.5);
|
|
color: white;
|
|
}
|
|
|
|
.next-button:active, .back-button:active, .submit-button:active {
|
|
transform: translateY(0);
|
|
box-shadow: 0 2px 8px rgba(58, 113, 228, 0.3);
|
|
}
|
|
|
|
/* Skip button styling */
|
|
.skip-button {
|
|
padding: 12px 24px;
|
|
border-radius: 8px;
|
|
font-weight: 600;
|
|
font-size: 16px;
|
|
transition: all 0.3s ease;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
background: linear-gradient(135deg, rgba(220, 53, 69, 0.9) 0%, rgba(220, 53, 69, 0.8) 100%);
|
|
color: white;
|
|
border: none;
|
|
box-shadow: 0 4px 10px rgba(220, 53, 69, 0.3);
|
|
cursor: pointer;
|
|
}
|
|
|
|
.skip-button:hover {
|
|
background: linear-gradient(135deg, rgba(220, 53, 69, 1) 0%, rgba(220, 53, 69, 0.9) 100%);
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 6px 15px rgba(220, 53, 69, 0.4);
|
|
}
|
|
|
|
.skip-button:active {
|
|
transform: translateY(0);
|
|
box-shadow: 0 2px 8px rgba(220, 53, 69, 0.3);
|
|
}
|
|
|
|
/* Error message styling */
|
|
.error-message {
|
|
background-color: rgba(220, 53, 69, 0.2);
|
|
color: #ff6b6b;
|
|
padding: 12px;
|
|
border-radius: 8px;
|
|
margin-bottom: 20px;
|
|
text-align: center;
|
|
border-left: 4px solid #dc3545;
|
|
display: none;
|
|
}
|
|
|
|
/* Success message */
|
|
.success-message {
|
|
background-color: rgba(40, 167, 69, 0.2);
|
|
color: #2ecc71;
|
|
padding: 12px;
|
|
border-radius: 8px;
|
|
margin-bottom: 20px;
|
|
text-align: center;
|
|
border-left: 4px solid #28a745;
|
|
}
|
|
|
|
/* QR code styling */
|
|
.qr-container {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
margin: 20px 0;
|
|
}
|
|
|
|
.qr-code {
|
|
background: white;
|
|
padding: 10px;
|
|
border-radius: 8px;
|
|
margin-bottom: 15px;
|
|
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
|
|
width: 64px;
|
|
height: 64px;
|
|
margin: 0 auto 15px;
|
|
}
|
|
|
|
.qr-code img {
|
|
width: 100%;
|
|
height: 100%;
|
|
display: block;
|
|
}
|
|
|
|
/* Responsive QR code for mobile */
|
|
@media (max-width: 768px) {
|
|
.qr-code {
|
|
width: 30%;
|
|
height: auto;
|
|
}
|
|
}
|
|
|
|
.secret-key {
|
|
font-family: monospace;
|
|
padding: 10px 15px;
|
|
background: rgba(28, 36, 54, 0.8);
|
|
border-radius: 8px;
|
|
border: 1px solid rgba(90, 109, 137, 0.3);
|
|
color: rgba(255, 255, 255, 0.9);
|
|
margin-bottom: 15px;
|
|
width: 100%;
|
|
text-align: center;
|
|
font-size: 14px;
|
|
user-select: all;
|
|
}
|
|
|
|
.copy-button {
|
|
background: transparent;
|
|
border: 1px solid rgba(90, 109, 137, 0.3);
|
|
color: rgba(255, 255, 255, 0.8);
|
|
padding: 8px 15px;
|
|
border-radius: 6px;
|
|
cursor: pointer;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
font-size: 14px;
|
|
transition: all 0.2s ease;
|
|
}
|
|
|
|
.copy-button:hover {
|
|
background: rgba(90, 109, 137, 0.1);
|
|
border-color: rgba(90, 109, 137, 0.5);
|
|
color: white;
|
|
}
|
|
|
|
/* Responsive adjustments */
|
|
@media (max-width: 768px) {
|
|
.login-container {
|
|
width: 95%;
|
|
}
|
|
|
|
.login-form {
|
|
padding: 20px;
|
|
}
|
|
|
|
.login-header {
|
|
padding: 20px 0;
|
|
}
|
|
|
|
.login-logo {
|
|
width: 60px;
|
|
height: 60px;
|
|
}
|
|
|
|
.form-actions {
|
|
flex-direction: column-reverse;
|
|
gap: 10px;
|
|
}
|
|
|
|
.next-button, .back-button, .submit-button {
|
|
width: 100%;
|
|
justify-content: center;
|
|
}
|
|
|
|
.step {
|
|
font-size: 0.75em;
|
|
padding: 8px 5px;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body class="login-page dark-mode">
|
|
<div class="login-container">
|
|
<div class="login-header">
|
|
<img src="./static/logo/256.png" alt="Huntarr Logo" class="login-logo huntarr-logo">
|
|
<h1>Huntarr</h1>
|
|
</div>
|
|
<div class="login-form">
|
|
<div class="setup-steps">
|
|
<div id="step1" class="step active">1. Create Account</div>
|
|
<div id="step2" class="step">2. Setup 2FA</div>
|
|
<div id="step3" class="step">3. Auth Mode</div>
|
|
<div id="step4" class="step">4. Finish</div>
|
|
</div>
|
|
|
|
<div id="accountSetup" class="setup-section active">
|
|
<h2>Create Your Account</h2>
|
|
<div class="form-group">
|
|
<label for="username">
|
|
<i class="fas fa-user"></i>
|
|
<span>Username</span>
|
|
</label>
|
|
<input type="text" id="username" name="username" required>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="password">
|
|
<i class="fas fa-lock"></i>
|
|
<span>Password</span>
|
|
</label>
|
|
<input type="password" id="password" name="password" required>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="confirm_password">
|
|
<i class="fas fa-check-circle"></i>
|
|
<span>Confirm Password</span>
|
|
</label>
|
|
<input type="password" id="confirm_password" name="confirm_password" required>
|
|
</div>
|
|
|
|
|
|
|
|
<div class="error-message" id="errorMessage" style="display: none;"></div>
|
|
<div class="form-actions">
|
|
<button type="button" id="accountNextButton" class="next-button">
|
|
<i class="fas fa-arrow-right"></i> Next
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="twoFactorSetup" class="setup-section">
|
|
<h2>Setup Two-Factor Authentication</h2>
|
|
<div class="qr-container">
|
|
<p>Scan this QR code with your auth app:</p>
|
|
<div class="qr-code" id="qrCode">
|
|
<img src="" alt="QR Code" style="display: none;"> <!-- Add img tag, initially hidden -->
|
|
</div>
|
|
<p>Or enter this code manually in your app:</p>
|
|
<div class="secret-key" id="secretKey">Generating...</div>
|
|
|
|
<div class="form-group" style="display: flex; flex-direction: column; align-items: center; margin: 20px 0;">
|
|
<label for="verificationCode" style="display: flex; align-items: center; justify-content: center; margin-bottom: 10px;">
|
|
<i class="fas fa-shield-alt" style="margin-right: 8px; color: #4a90e2;"></i>
|
|
<span>Verification Code</span>
|
|
</label>
|
|
<input type="text" id="verificationCode" placeholder="Enter 6-digit code" maxlength="6" style="text-align: center; width: 60%; max-width: 300px;">
|
|
</div>
|
|
|
|
<div class="form-actions">
|
|
<button type="button" id="twoFactorNextButton" class="next-button" style="margin-right: 10px;">
|
|
<i class="fas fa-check"></i> Verify & Continue
|
|
</button>
|
|
<button id="skip2FALink" class="skip-button">
|
|
<i class="fas fa-times"></i> Skip 2FA setup
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="authModeSetup" class="setup-section">
|
|
<h2>Choose Authentication Mode</h2>
|
|
<p>Select how users will authenticate with Huntarr</p>
|
|
|
|
<div class="form-group" style="margin-top: 25px;">
|
|
<div style="background-color: rgba(28, 36, 54, 0.8); border-radius: 10px; padding: 15px; border: 1px solid rgba(65, 105, 225, 0.3);">
|
|
<div style="display: flex; align-items: flex-start;">
|
|
<div style="margin-right: 12px; margin-top: 2px;">
|
|
<i class="fas fa-shield-alt" style="color: #4a90e2; font-size: 18px;"></i>
|
|
</div>
|
|
<div>
|
|
<label for="auth_mode" style="font-weight: 600; display: flex; align-items: center; margin-bottom: 8px;">
|
|
<span>Authentication Mode</span>
|
|
</label>
|
|
<div style="margin-bottom: 10px;">
|
|
<select id="auth_mode" style="width: 100%; padding: 8px; background-color: rgba(28, 36, 54, 0.8); color: #fff; border: 1px solid rgba(65, 105, 225, 0.6); border-radius: 5px;">
|
|
<option value="login" selected>Login Mode</option>
|
|
<option value="local_bypass">Local Bypass Mode</option>
|
|
<option value="no_login">No Login Mode</option>
|
|
</select>
|
|
</div>
|
|
<div style="font-size: 13px; color: rgba(255, 255, 255, 0.7); margin-top: 5px;">
|
|
<p><strong>Login Mode:</strong> Standard login required for all connections</p>
|
|
<p><strong>Local Bypass Mode:</strong> Only local network connections (192.168.x.x, 10.x.x.x) bypass login</p>
|
|
<p><strong>No Login Mode:</strong> Completely disable authentication</p>
|
|
</div>
|
|
<p style="font-size: 13px; color: #ff9966; margin-top: 5px;">
|
|
<i class="fas fa-exclamation-triangle"></i> <strong>Warning:</strong> Only use No Login Mode if your reverse proxy (e.g., Cloudflare, Nginx) is properly securing access!
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="error-message" id="authModeErrorMessage" style="display: none;"></div>
|
|
<div class="form-actions">
|
|
<button type="button" id="authModeNextButton" class="next-button">
|
|
<i class="fas fa-arrow-right"></i> Next
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="setupComplete" class="setup-section">
|
|
<h2>Setup Complete</h2>
|
|
<p>Your Huntarr account has been created successfully!</p>
|
|
<div style="text-align: center; margin-top: 20px;">
|
|
<div style="background-color: #2c2c2c; border-radius: 8px; padding: 15px; margin-bottom: 20px;">
|
|
<p>
|
|
<i class="fas fa-heart thankyou-heart"></i>
|
|
</p>
|
|
<p style="font-weight: bold; margin-top: 10px;">Thank You For Using Huntarr</p>
|
|
<p style="color: #bbb; font-size: 0.95em; margin-top: 10px; line-height: 1.4; text-align: left;">
|
|
If you love the program, any future donation to my daughter's college fund would make her day! Regardless, enjoy Huntarr and please join us on Discord and Reddit for community support.
|
|
</p>
|
|
<p style="color: #aaa; font-size: 0.9em; margin-top: 10px; text-align: left;">
|
|
- Admin9705 & Huntarr Crew
|
|
</p>
|
|
</div>
|
|
<p><i class="fas fa-check-circle" style="color: #4CAF50;"></i> You can now proceed to the main interface.</p>
|
|
</div>
|
|
<div class="form-actions" style="justify-content: center;">
|
|
<button type="button" id="finishSetupButton" class="submit-button">
|
|
<i class="fas fa-home"></i> Go to Dashboard
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Pass base URL configuration to JavaScript -->
|
|
<script>window.HUNTARR_BASE_URL = '{{ base_url|default("", true) }}';</script>
|
|
<!-- Pass global scripts -->
|
|
{% include 'components/scripts.html' %}
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
// Elements
|
|
const steps = document.querySelectorAll('.step');
|
|
const screens = document.querySelectorAll('.setup-section');
|
|
const errorMessage = document.getElementById('errorMessage');
|
|
|
|
// Account setup elements
|
|
const usernameInput = document.getElementById('username');
|
|
const passwordInput = document.getElementById('password');
|
|
const confirmPasswordInput = document.getElementById('confirm_password');
|
|
const accountNextButton = document.getElementById('accountNextButton');
|
|
|
|
// 2FA setup elements
|
|
const qrCodeElement = document.getElementById('qrCode');
|
|
const secretKeyElement = document.getElementById('secretKey');
|
|
const verificationCodeInput = document.getElementById('verificationCode');
|
|
const skip2FALink = document.getElementById('skip2FALink');
|
|
const twoFactorNextButton = document.getElementById('twoFactorNextButton');
|
|
|
|
// Auth Mode setup elements
|
|
const authModeSelect = document.getElementById('auth_mode');
|
|
const authModeNextButton = document.getElementById('authModeNextButton');
|
|
const authModeErrorMessage = document.getElementById('authModeErrorMessage');
|
|
|
|
// Complete setup elements
|
|
const finishSetupButton = document.getElementById('finishSetupButton');
|
|
|
|
// Current step tracking
|
|
let currentStep = 1;
|
|
let accountCreated = false;
|
|
let twoFactorEnabled = false;
|
|
|
|
// Store user data
|
|
let userData = {
|
|
username: '',
|
|
password: ''
|
|
};
|
|
|
|
// Show a specific step
|
|
function showStep(step) {
|
|
steps.forEach((s, index) => {
|
|
if (index + 1 < step) {
|
|
s.classList.remove('active');
|
|
s.classList.add('completed');
|
|
} else if (index + 1 === step) {
|
|
s.classList.add('active');
|
|
s.classList.remove('completed');
|
|
} else {
|
|
s.classList.remove('active');
|
|
s.classList.remove('completed');
|
|
}
|
|
});
|
|
|
|
// For the four sections: Account, 2FA, Auth Mode, Complete
|
|
if (step === 1) {
|
|
document.getElementById('accountSetup').classList.add('active');
|
|
document.getElementById('twoFactorSetup').classList.remove('active');
|
|
document.getElementById('authModeSetup').classList.remove('active');
|
|
document.getElementById('setupComplete').classList.remove('active');
|
|
} else if (step === 2) {
|
|
document.getElementById('accountSetup').classList.remove('active');
|
|
document.getElementById('twoFactorSetup').classList.add('active');
|
|
document.getElementById('authModeSetup').classList.remove('active');
|
|
document.getElementById('setupComplete').classList.remove('active');
|
|
} else if (step === 3) {
|
|
document.getElementById('accountSetup').classList.remove('active');
|
|
document.getElementById('twoFactorSetup').classList.remove('active');
|
|
document.getElementById('authModeSetup').classList.add('active');
|
|
document.getElementById('setupComplete').classList.remove('active');
|
|
} else if (step === 4) {
|
|
document.getElementById('accountSetup').classList.remove('active');
|
|
document.getElementById('twoFactorSetup').classList.remove('active');
|
|
document.getElementById('authModeSetup').classList.remove('active');
|
|
document.getElementById('setupComplete').classList.add('active');
|
|
}
|
|
|
|
currentStep = step;
|
|
}
|
|
|
|
// Show error message
|
|
function showError(message) {
|
|
errorMessage.textContent = message;
|
|
errorMessage.style.display = 'block';
|
|
|
|
// Hide after 5 seconds
|
|
setTimeout(() => {
|
|
errorMessage.style.display = 'none';
|
|
}, 5000);
|
|
}
|
|
|
|
// Password validation function
|
|
function validatePassword(password) {
|
|
// Only check for minimum length of 8 characters
|
|
if (password.length < 8) {
|
|
return 'Password must be at least 8 characters long.';
|
|
}
|
|
return null; // Password is valid
|
|
}
|
|
|
|
// Account creation
|
|
accountNextButton.addEventListener('click', function() {
|
|
const username = usernameInput.value.trim(); // Trim whitespace
|
|
const password = passwordInput.value;
|
|
const confirmPassword = confirmPasswordInput.value;
|
|
// No longer needed here - will be captured in step 3
|
|
|
|
if (!username || !password || !confirmPassword) {
|
|
showError('All fields are required');
|
|
return;
|
|
}
|
|
|
|
// Add username length validation
|
|
if (username.length < 3) {
|
|
showError('Username must be at least 3 characters long');
|
|
return;
|
|
}
|
|
|
|
if (password !== confirmPassword) {
|
|
showError('Passwords do not match');
|
|
return;
|
|
}
|
|
|
|
// Validate password complexity
|
|
const passwordError = validatePassword(password);
|
|
if (passwordError) {
|
|
showError(passwordError);
|
|
return;
|
|
}
|
|
|
|
// Store user data
|
|
userData.username = username;
|
|
userData.password = password;
|
|
|
|
if (accountCreated) {
|
|
// If account already created, just move to next step
|
|
showStep(2);
|
|
return;
|
|
}
|
|
|
|
// Create user account with improved error handling
|
|
HuntarrUtils.fetchWithTimeout('/setup', { // Corrected endpoint from /api/setup to /setup
|
|
method: 'POST',
|
|
redirect: 'error', // Add this line to prevent following redirects
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify({
|
|
username: username,
|
|
password: password,
|
|
confirm_password: confirmPassword // Keep confirm_password if backend expects it, otherwise remove
|
|
})
|
|
})
|
|
.then(response => {
|
|
// Check if response is ok before parsing JSON
|
|
if (!response.ok) {
|
|
// Check content type to see if it's likely JSON
|
|
const contentType = response.headers.get("content-type");
|
|
if (contentType && contentType.indexOf("application/json") !== -1) {
|
|
// If it seems like JSON, try to parse it for an error message
|
|
return response.json().then(data => {
|
|
// Use data.error first, then data.message as fallback
|
|
throw new Error(data.error || data.message || `Server error: ${response.status}`);
|
|
});
|
|
} else {
|
|
// If not JSON (e.g., HTML error page), throw a generic HTTP error
|
|
throw new Error(`HTTP error! status: ${response.status}`);
|
|
}
|
|
}
|
|
// If response is ok, parse the JSON body
|
|
return response.json();
|
|
})
|
|
.then(data => { // This block only runs if response.ok was true and response.json() succeeded
|
|
if (data.success) {
|
|
accountCreated = true;
|
|
console.log('Account created successfully. User credentials should be saved to credentials.json');
|
|
|
|
// Generate 2FA setup - Use the correct endpoint and method
|
|
HuntarrUtils.fetchWithTimeout('/api/user/2fa/setup', { method: 'POST' }) // Specify POST method
|
|
.then(response => {
|
|
// Check for unauthorized specifically
|
|
if (response.status === 401) {
|
|
throw new Error('Unauthorized - Session likely not established yet.');
|
|
}
|
|
if (!response.ok) {
|
|
// Try to parse error from JSON response
|
|
return response.json().then(errData => {
|
|
throw new Error(errData.error || `Server error: ${response.status}`);
|
|
}).catch(() => {
|
|
// Fallback if response is not JSON
|
|
throw new Error(`Server error: ${response.status}`);
|
|
});
|
|
}
|
|
return response.json();
|
|
})
|
|
.then(twoFactorData => {
|
|
if (twoFactorData.success) {
|
|
// Use the correct property 'qr_code_url' and set the img src directly
|
|
const qrCodeImg = qrCodeElement.querySelector('img'); // Find the img tag within the div
|
|
if (qrCodeImg) {
|
|
qrCodeImg.src = twoFactorData.qr_code_url; // Set src directly
|
|
qrCodeImg.style.display = 'block'; // Ensure it's visible
|
|
} else {
|
|
// Fallback if img tag wasn't there initially
|
|
qrCodeElement.innerHTML = `<img src="${twoFactorData.qr_code_url}" alt="QR Code" style="display: block; max-width: 100%; height: auto;">`;
|
|
}
|
|
secretKeyElement.textContent = twoFactorData.secret;
|
|
showStep(2);
|
|
} else {
|
|
// Use .error if available, otherwise provide a default
|
|
showError('Failed to generate 2FA setup: ' + (twoFactorData.error || 'Unknown error'));
|
|
}
|
|
})
|
|
.catch(error => {
|
|
console.error('Error generating 2FA:', error);
|
|
// Display the specific error message caught
|
|
showError('Failed to generate 2FA setup: ' + error.message);
|
|
});
|
|
} else {
|
|
showError(data.error || 'Failed to create account'); // Use .error
|
|
}
|
|
})
|
|
.catch(error => { // Catches errors thrown from the .then blocks above or network errors
|
|
console.error('Setup error:', error);
|
|
showError('Error: ' + error.message); // Display the error message
|
|
});
|
|
});
|
|
|
|
// 2FA setup navigation
|
|
twoFactorNextButton.addEventListener('click', function() {
|
|
const code = verificationCodeInput.value;
|
|
if (!code || code.length !== 6 || !/^\d{6}$/.test(code)) { // Add validation
|
|
showError('Please enter a valid 6-digit verification code');
|
|
return;
|
|
}
|
|
|
|
// Verify 2FA code - Use the correct endpoint
|
|
HuntarrUtils.fetchWithTimeout('/api/user/2fa/verify', { // Corrected endpoint
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify({ code: code })
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (data.success) {
|
|
twoFactorEnabled = true;
|
|
showStep(3); // Go to Auth Mode step
|
|
} else {
|
|
showError(data.message || 'Invalid verification code');
|
|
}
|
|
})
|
|
.catch(error => {
|
|
console.error('Error verifying 2FA code:', error);
|
|
showError('Failed to verify code');
|
|
});
|
|
});
|
|
|
|
// Skip 2FA setup
|
|
skip2FALink.addEventListener('click', function() {
|
|
showStep(3); // Go to Auth Mode step
|
|
});
|
|
|
|
// Auth Mode setup navigation
|
|
authModeNextButton.addEventListener('click', function() {
|
|
// Get the selected auth mode
|
|
const selectedAuthMode = authModeSelect.value;
|
|
|
|
// Save the authentication mode settings
|
|
HuntarrUtils.fetchWithTimeout('/api/settings/general', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify({
|
|
base_url: window.HUNTARR_BASE_URL,
|
|
auth_mode: selectedAuthMode,
|
|
local_access_bypass: selectedAuthMode === 'local_bypass',
|
|
proxy_auth_bypass: selectedAuthMode === 'no_login'
|
|
})
|
|
})
|
|
.then(response => {
|
|
if (!response.ok) {
|
|
return response.json().then(data => {
|
|
throw new Error(data.error || `Error: ${response.status}`);
|
|
});
|
|
}
|
|
return response.json();
|
|
})
|
|
.then(data => {
|
|
// Proceed to the finish step
|
|
showStep(4);
|
|
})
|
|
.catch(error => {
|
|
console.error('Error saving auth mode settings:', error);
|
|
authModeErrorMessage.textContent = error.message || 'Error saving authentication settings';
|
|
authModeErrorMessage.style.display = 'block';
|
|
|
|
// Hide after 5 seconds
|
|
setTimeout(() => {
|
|
authModeErrorMessage.style.display = 'none';
|
|
}, 5000);
|
|
});
|
|
});
|
|
|
|
// Complete setup navigation
|
|
finishSetupButton.addEventListener('click', function() {
|
|
window.location.href = '/';
|
|
});
|
|
|
|
// Allow pressing Enter to continue
|
|
document.addEventListener('keydown', function(e) {
|
|
if (e.key === 'Enter') {
|
|
e.preventDefault(); // Prevent form submission
|
|
if (currentStep === 1 && document.activeElement !== accountNextButton) {
|
|
accountNextButton.click();
|
|
} else if (currentStep === 2 && document.activeElement !== twoFactorNextButton) {
|
|
twoFactorNextButton.click();
|
|
} else if (currentStep === 3 && document.activeElement !== authModeNextButton) {
|
|
authModeNextButton.click();
|
|
} else if (currentStep === 4 && document.activeElement !== finishSetupButton) {
|
|
finishSetupButton.click();
|
|
}
|
|
}
|
|
});
|
|
|
|
// Always use dark mode
|
|
document.body.classList.add('dark-mode');
|
|
localStorage.setItem('huntarr-dark-mode', 'true');
|
|
});
|
|
</script>
|
|
</body>
|
|
</html> |