683 lines
23 KiB
HTML
683 lines
23 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Sign Up | {{ appName }}</title>
|
|
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
|
|
<style>
|
|
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=Inter:wght@400;500;600&display=swap');
|
|
|
|
:root {
|
|
--brand-primary: #6366f1;
|
|
--brand-hover: #4f46e5;
|
|
--brand-success: #10b981;
|
|
--brand-error: #ef4444;
|
|
--text-main: #0f172a;
|
|
--text-muted: #64748b;
|
|
--bg-body: #f8fafc;
|
|
--border-color: #e2e8f0;
|
|
--shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
|
|
--shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
|
|
--radius-xl: 2rem;
|
|
--radius-lg: 0.75rem;
|
|
}
|
|
|
|
* {
|
|
box-sizing: border-box;
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
|
|
body {
|
|
font-family: 'Inter', sans-serif;
|
|
background-color: var(--bg-body);
|
|
background-image:
|
|
radial-gradient(at 0% 0%, hsla(253,16%,95%,1) 0, transparent 50%),
|
|
radial-gradient(at 100% 0%, hsla(225,39%,90%,1) 0, transparent 50%);
|
|
height: 100vh;
|
|
width: 100vw;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 1rem;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.login-card {
|
|
max-width: 448px;
|
|
width: 100%;
|
|
background: #ffffff;
|
|
border-radius: var(--radius-xl);
|
|
box-shadow: var(--shadow-xl);
|
|
border: 1px solid var(--border-color);
|
|
display: flex;
|
|
flex-direction: column;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.card-content {
|
|
padding: 2.5rem;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
|
|
.brand-header {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 0.75rem;
|
|
margin-bottom: 2rem;
|
|
}
|
|
|
|
.brand-icon {
|
|
width: 32px;
|
|
height: 32px;
|
|
background: var(--brand-primary);
|
|
border-radius: 8px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
color: white;
|
|
box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
|
|
font-size: 0.875rem;
|
|
}
|
|
|
|
.brand-name {
|
|
font-family: 'Space Grotesk', sans-serif;
|
|
font-size: 1.25rem;
|
|
font-weight: 700;
|
|
color: var(--text-main);
|
|
letter-spacing: -0.025em;
|
|
}
|
|
|
|
h2 {
|
|
font-family: 'Space Grotesk', sans-serif;
|
|
font-size: 1.875rem;
|
|
font-weight: 700;
|
|
color: var(--text-main);
|
|
margin-bottom: 0.5rem;
|
|
letter-spacing: -0.025em;
|
|
}
|
|
|
|
.description {
|
|
color: var(--text-muted);
|
|
font-size: 0.875rem;
|
|
margin-bottom: 2rem;
|
|
line-height: 1.5;
|
|
}
|
|
|
|
.form-group {
|
|
margin-bottom: 1.5rem;
|
|
}
|
|
|
|
.input-container {
|
|
display: flex;
|
|
align-items: center;
|
|
background: #ffffff;
|
|
border: 2px solid var(--border-color);
|
|
border-radius: var(--radius-lg);
|
|
padding: 0 1rem;
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.input-container:focus-within {
|
|
border-color: var(--brand-primary);
|
|
box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
|
|
}
|
|
|
|
.input-container i {
|
|
color: var(--text-muted);
|
|
margin-right: 0.75rem;
|
|
font-size: 1rem;
|
|
}
|
|
|
|
input {
|
|
width: 100%;
|
|
border: none;
|
|
outline: none;
|
|
padding: 0.875rem 0;
|
|
font-size: 1rem;
|
|
color: var(--text-main);
|
|
background: transparent;
|
|
}
|
|
|
|
.btn {
|
|
width: 100%;
|
|
padding: 1rem;
|
|
border-radius: var(--radius-lg);
|
|
border: none;
|
|
font-size: 1rem;
|
|
font-weight: 700;
|
|
cursor: pointer;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
gap: 0.5rem;
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.btn-primary {
|
|
background: var(--brand-primary);
|
|
color: white;
|
|
box-shadow: 0 4px 10px rgba(99, 102, 241, 0.2);
|
|
}
|
|
|
|
.btn-primary:hover:not(:disabled) {
|
|
background: var(--brand-hover);
|
|
transform: translateY(-1px);
|
|
}
|
|
|
|
.btn-primary:disabled {
|
|
opacity: 0.7;
|
|
cursor: not-allowed;
|
|
}
|
|
|
|
.btn-text {
|
|
background: transparent;
|
|
color: var(--text-muted);
|
|
border: none;
|
|
font-size: 0.875rem;
|
|
font-weight: 500;
|
|
margin-top: 1rem;
|
|
cursor: pointer;
|
|
transition: color 0.2s;
|
|
}
|
|
|
|
.btn-text:hover {
|
|
color: var(--brand-primary);
|
|
}
|
|
|
|
.back-link {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 0.5rem;
|
|
color: var(--text-muted);
|
|
font-size: 0.75rem;
|
|
font-weight: 700;
|
|
text-decoration: none;
|
|
margin-bottom: 1.5rem;
|
|
cursor: pointer;
|
|
transition: color 0.2s;
|
|
}
|
|
|
|
.back-link:hover {
|
|
color: var(--brand-primary);
|
|
}
|
|
|
|
.identity-chip {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 0.5rem;
|
|
background: var(--bg-body);
|
|
border: 1px solid var(--border-color);
|
|
padding: 0.375rem 0.75rem;
|
|
border-radius: 0.5rem;
|
|
font-size: 0.75rem;
|
|
color: var(--text-muted);
|
|
width: fit-content;
|
|
margin-bottom: 1.5rem;
|
|
}
|
|
|
|
.hidden { display: none !important; }
|
|
|
|
.error-box {
|
|
background: #fef2f2;
|
|
border-left: 4px solid var(--brand-error);
|
|
color: #b91c1c;
|
|
padding: 0.75rem;
|
|
border-radius: 0 0.5rem 0.5rem 0;
|
|
font-size: 0.75rem;
|
|
margin-bottom: 1.5rem;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 0.5rem;
|
|
}
|
|
|
|
.success-state {
|
|
text-align: center;
|
|
padding: 1rem 0;
|
|
}
|
|
|
|
.success-icon {
|
|
width: 64px;
|
|
height: 64px;
|
|
background: #ecfdf5;
|
|
color: var(--brand-success);
|
|
border-radius: 50%;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
font-size: 1.5rem;
|
|
margin: 0 auto 1.5rem;
|
|
}
|
|
|
|
.step-transition {
|
|
animation: fadeInScale 0.4s cubic-bezier(0.16, 1, 0.3, 1);
|
|
}
|
|
|
|
@keyframes fadeInScale {
|
|
from { opacity: 0; transform: scale(0.99) translateY(5px); }
|
|
to { opacity: 1; transform: scale(1) translateY(0); }
|
|
}
|
|
|
|
.loader {
|
|
width: 18px;
|
|
height: 18px;
|
|
border: 2px solid rgba(255,255,255,0.3);
|
|
border-top-color: #fff;
|
|
border-radius: 50%;
|
|
animation: spin 0.8s linear infinite;
|
|
}
|
|
|
|
@keyframes spin {
|
|
to { transform: rotate(360deg); }
|
|
}
|
|
|
|
.toggle-btn {
|
|
background: none;
|
|
border: none;
|
|
color: var(--text-muted);
|
|
cursor: pointer;
|
|
padding: 0.5rem;
|
|
}
|
|
|
|
/* Mobile and popup responsiveness */
|
|
@media (max-width: 768px) {
|
|
body {
|
|
padding: 0;
|
|
align-items: stretch;
|
|
justify-content: stretch;
|
|
}
|
|
|
|
.login-card {
|
|
max-width: none;
|
|
width: 100%;
|
|
height: 100vh;
|
|
border-radius: 0;
|
|
border: none;
|
|
box-shadow: none;
|
|
}
|
|
|
|
.card-content {
|
|
padding: 1.5rem;
|
|
height: 100%;
|
|
justify-content: flex-start;
|
|
padding-top: 2rem;
|
|
}
|
|
|
|
.brand-header {
|
|
margin-bottom: 1.5rem;
|
|
}
|
|
|
|
h2 {
|
|
font-size: 1.5rem;
|
|
}
|
|
|
|
.description {
|
|
font-size: 0.75rem;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<div class="login-card">
|
|
<div class="card-content">
|
|
<!-- Brand -->
|
|
<div class="brand-header">
|
|
<div class="brand-icon">
|
|
<i class="fa-solid fa-key"></i>
|
|
</div>
|
|
<span class="brand-name">{{ appName }}</span>
|
|
</div>
|
|
|
|
<!-- Stage 1: Email -->
|
|
<div id="stage1" class="step-transition">
|
|
<h2>Create Account</h2>
|
|
<p class="description">Let's get you started with your new account</p>
|
|
|
|
<form id="emailForm" onsubmit="toStage2(event)">
|
|
<div class="form-group">
|
|
<div class="input-container">
|
|
<i class="fa-solid fa-envelope"></i>
|
|
<input type="email" id="email" required placeholder="name@company.com">
|
|
</div>
|
|
</div>
|
|
|
|
<button type="submit" id="nextBtn" class="btn btn-primary">
|
|
<span id="nextLoader" class="loader hidden"></span>
|
|
<span id="nextText">Next</span>
|
|
<i class="fa-solid fa-arrow-right" style="font-size: 0.75rem; opacity: 0.7;" id="nextIcon"></i>
|
|
</button>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- Stage 2: Name & Username -->
|
|
<div id="stage2" class="step-transition hidden">
|
|
<div class="back-link" onclick="backToStage1()">
|
|
<i class="fa-solid fa-chevron-left"></i>
|
|
Change email
|
|
</div>
|
|
|
|
<h2>Personal Info</h2>
|
|
<div class="identity-chip">
|
|
<i class="fa-solid fa-envelope"></i>
|
|
<span id="displayEmail"></span>
|
|
</div>
|
|
|
|
<form id="infoForm" onsubmit="toStage3(event)">
|
|
<div class="form-group">
|
|
<div class="input-container">
|
|
<i class="fa-solid fa-user"></i>
|
|
<input type="text" id="name" required placeholder="Full name">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<div class="input-container">
|
|
<i class="fa-solid fa-at"></i>
|
|
<input type="text" id="username" required placeholder="Username">
|
|
</div>
|
|
</div>
|
|
|
|
<button type="submit" id="infoBtn" class="btn btn-primary">
|
|
<span id="infoLoader" class="loader hidden"></span>
|
|
<span id="infoText">Next</span>
|
|
<i class="fa-solid fa-arrow-right" style="font-size: 0.75rem; opacity: 0.7;" id="infoIcon"></i>
|
|
</button>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- Stage 3: Password -->
|
|
<div id="stage3" class="step-transition hidden">
|
|
<div class="back-link" onclick="backToStage2()">
|
|
<i class="fa-solid fa-chevron-left"></i>
|
|
Back
|
|
</div>
|
|
|
|
<h2>Set Password</h2>
|
|
<p class="description">Create a strong password for your account</p>
|
|
|
|
<form id="passwordForm" onsubmit="handleSignup(event)">
|
|
<div class="form-group">
|
|
<div class="input-container">
|
|
<i class="fa-solid fa-lock"></i>
|
|
<input type="password" id="password" required placeholder="Enter password" autocomplete="new-password">
|
|
<button type="button" class="toggle-btn" onclick="togglePassword()">
|
|
<i id="eyeIcon" class="fa-solid fa-eye"></i>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<div class="input-container">
|
|
<i class="fa-solid fa-lock"></i>
|
|
<input type="password" id="confirmPassword" required placeholder="Confirm password" autocomplete="new-password">
|
|
<button type="button" class="toggle-btn" onclick="toggleConfirmPassword()">
|
|
<i id="confirmEyeIcon" class="fa-solid fa-eye"></i>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="passwordError" class="error-box hidden">
|
|
<i class="fa-solid fa-circle-exclamation"></i>
|
|
<span id="passwordErrorText">Passwords do not match</span>
|
|
</div>
|
|
|
|
<button type="submit" id="signupBtn" class="btn btn-primary">
|
|
<span id="signupLoader" class="loader hidden"></span>
|
|
<span id="signupText">Create Account</span>
|
|
</button>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- Success Stage -->
|
|
<div id="successStage" class="step-transition hidden">
|
|
<div class="success-state">
|
|
<div class="success-icon">
|
|
<i class="fa-solid fa-check"></i>
|
|
</div>
|
|
<h2>Account Created!</h2>
|
|
<p class="description">Welcome to {{ appName }}! Your account has been created successfully.</p>
|
|
<button class="btn btn-primary" onclick="window.location.href='/'">
|
|
Go to Dashboard
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
// Check if in popup and apply fullscreen styling
|
|
if (window.opener || window.self !== window.top) {
|
|
document.documentElement.style.width = '100vw';
|
|
document.documentElement.style.height = '100vh';
|
|
document.body.style.width = '100vw';
|
|
document.body.style.height = '100vh';
|
|
document.querySelector('.login-card').style.maxWidth = 'none';
|
|
document.querySelector('.login-card').style.width = '100%';
|
|
document.querySelector('.login-card').style.height = '100vh';
|
|
document.querySelector('.login-card').style.borderRadius = '0';
|
|
document.querySelector('.login-card').style.border = 'none';
|
|
document.querySelector('.login-card').style.boxShadow = 'none';
|
|
}
|
|
|
|
const stages = {
|
|
1: document.getElementById('stage1'),
|
|
2: document.getElementById('stage2'),
|
|
3: document.getElementById('stage3'),
|
|
success: document.getElementById('successStage')
|
|
};
|
|
|
|
const emailInput = document.getElementById('email');
|
|
const nameInput = document.getElementById('name');
|
|
const usernameInput = document.getElementById('username');
|
|
const passwordInput = document.getElementById('password');
|
|
const confirmPasswordInput = document.getElementById('confirmPassword');
|
|
const displayEmail = document.getElementById('displayEmail');
|
|
const passwordError = document.getElementById('passwordError');
|
|
const passwordErrorText = document.getElementById('passwordErrorText');
|
|
|
|
async function sendSignupRequest(email, name, username, password) {
|
|
try {
|
|
const response = await fetch("{{ url_for('handleSignup') }}", {
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
body: JSON.stringify({
|
|
"email": email,
|
|
"name": name,
|
|
"username": username,
|
|
"password": password
|
|
}),
|
|
});
|
|
if (!response.ok) {
|
|
return { success: false, message: "Signup failed" };
|
|
}
|
|
const result = await response.json();
|
|
return { success: true, result };
|
|
} catch (error) {
|
|
console.error(error.message);
|
|
return { success: false, message: error.message };
|
|
}
|
|
}
|
|
|
|
async function sendLoginRequest(username, password) {
|
|
try {
|
|
const response = await fetch("{{ url_for('handleLogin') }}", {
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
body: JSON.stringify({ "username": username, "password": password }),
|
|
});
|
|
if (!response.ok) {
|
|
return false;
|
|
}
|
|
const result = await response.json();
|
|
if (result != "Invalid username or password") {
|
|
document.cookie = `auth_token=${result}`;
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
} catch (error) {
|
|
console.error(error.message);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function switchStage(to) {
|
|
Object.values(stages).forEach(s => s.classList.add('hidden'));
|
|
stages[to].classList.remove('hidden');
|
|
}
|
|
|
|
function toStage2(e) {
|
|
e.preventDefault();
|
|
const btn = document.getElementById('nextBtn');
|
|
const loader = document.getElementById('nextLoader');
|
|
const text = document.getElementById('nextText');
|
|
const icon = document.getElementById('nextIcon');
|
|
|
|
btn.disabled = true;
|
|
loader.classList.remove('hidden');
|
|
icon.classList.add('hidden');
|
|
text.innerText = 'Verifying...';
|
|
|
|
setTimeout(() => {
|
|
const email = emailInput.value;
|
|
displayEmail.innerText = email;
|
|
switchStage(2);
|
|
nameInput.value = '';
|
|
usernameInput.value = '';
|
|
nameInput.focus();
|
|
|
|
btn.disabled = false;
|
|
loader.classList.add('hidden');
|
|
icon.classList.remove('hidden');
|
|
text.innerText = 'Next';
|
|
}, 600);
|
|
}
|
|
|
|
function toStage3(e) {
|
|
e.preventDefault();
|
|
const btn = document.getElementById('infoBtn');
|
|
const loader = document.getElementById('infoLoader');
|
|
const text = document.getElementById('infoText');
|
|
const icon = document.getElementById('infoIcon');
|
|
|
|
btn.disabled = true;
|
|
loader.classList.remove('hidden');
|
|
icon.classList.add('hidden');
|
|
text.innerText = 'Next...';
|
|
|
|
setTimeout(() => {
|
|
switchStage(3);
|
|
passwordError.classList.add('hidden');
|
|
passwordInput.value = '';
|
|
confirmPasswordInput.value = '';
|
|
passwordInput.focus();
|
|
|
|
btn.disabled = false;
|
|
loader.classList.add('hidden');
|
|
icon.classList.remove('hidden');
|
|
text.innerText = 'Next';
|
|
}, 600);
|
|
}
|
|
|
|
function backToStage1() {
|
|
switchStage(1);
|
|
emailInput.focus();
|
|
}
|
|
|
|
function backToStage2() {
|
|
switchStage(2);
|
|
nameInput.focus();
|
|
}
|
|
|
|
function togglePassword() {
|
|
const eyeIcon = document.getElementById('eyeIcon');
|
|
if (passwordInput.type === 'password') {
|
|
passwordInput.type = 'text';
|
|
eyeIcon.classList.replace('fa-eye', 'fa-eye-slash');
|
|
} else {
|
|
passwordInput.type = 'password';
|
|
eyeIcon.classList.replace('fa-eye-slash', 'fa-eye');
|
|
}
|
|
}
|
|
|
|
function toggleConfirmPassword() {
|
|
const eyeIcon = document.getElementById('confirmEyeIcon');
|
|
if (confirmPasswordInput.type === 'password') {
|
|
confirmPasswordInput.type = 'text';
|
|
eyeIcon.classList.replace('fa-eye', 'fa-eye-slash');
|
|
} else {
|
|
confirmPasswordInput.type = 'password';
|
|
eyeIcon.classList.replace('fa-eye-slash', 'fa-eye');
|
|
}
|
|
}
|
|
|
|
async function handleSignup(e) {
|
|
e.preventDefault();
|
|
|
|
const password = passwordInput.value.trim();
|
|
const confirmPassword = confirmPasswordInput.value.trim();
|
|
|
|
if (password !== confirmPassword) {
|
|
passwordErrorText.innerText = 'Passwords do not match';
|
|
passwordError.classList.remove('hidden');
|
|
return;
|
|
}
|
|
|
|
if (password.length < 6) {
|
|
passwordErrorText.innerText = 'Password must be at least 6 characters';
|
|
passwordError.classList.remove('hidden');
|
|
return;
|
|
}
|
|
|
|
const btn = document.getElementById('signupBtn');
|
|
const loader = document.getElementById('signupLoader');
|
|
const text = document.getElementById('signupText');
|
|
|
|
passwordError.classList.add('hidden');
|
|
btn.disabled = true;
|
|
loader.classList.remove('hidden');
|
|
text.innerText = 'Creating account...';
|
|
|
|
const result = await sendSignupRequest(
|
|
emailInput.value,
|
|
nameInput.value,
|
|
usernameInput.value,
|
|
password
|
|
);
|
|
|
|
setTimeout(() => {
|
|
if (result.success) {
|
|
text.innerText = 'Account created!';
|
|
btn.style.backgroundColor = 'var(--brand-success)';
|
|
|
|
setTimeout(async () => {
|
|
text.innerText = 'Logging in...';
|
|
const loginSuccess = await sendLoginRequest(usernameInput.value, password);
|
|
|
|
if (loginSuccess) {
|
|
text.innerText = 'Welcome!';
|
|
setTimeout(() => window.location.href = '/', 500);
|
|
} else {
|
|
text.innerText = 'Redirecting...';
|
|
setTimeout(() => window.location.href = '/', 1000);
|
|
}
|
|
}, 800);
|
|
} else {
|
|
passwordErrorText.innerText = result.message || 'Signup failed';
|
|
passwordError.classList.remove('hidden');
|
|
btn.disabled = false;
|
|
loader.classList.add('hidden');
|
|
text.innerText = 'Create Account';
|
|
}
|
|
}, 1000);
|
|
}
|
|
</script>
|
|
</body>
|
|
</html> |