@israelGPT generate me CSS for my shitty reset password page
This commit is contained in:
parent
92f8d4ef61
commit
1eec497e5c
2 changed files with 240 additions and 367 deletions
|
|
@ -1,367 +0,0 @@
|
||||||
<!doctype html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
||||||
<title>Monochrome — Login</title>
|
|
||||||
<style>
|
|
||||||
*,
|
|
||||||
*::before,
|
|
||||||
*::after {
|
|
||||||
box-sizing: border-box;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
font-family:
|
|
||||||
'Inter',
|
|
||||||
-apple-system,
|
|
||||||
BlinkMacSystemFont,
|
|
||||||
'Segoe UI',
|
|
||||||
Roboto,
|
|
||||||
sans-serif;
|
|
||||||
background: #0a0a0a;
|
|
||||||
color: #e0e0e0;
|
|
||||||
min-height: 100vh;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.login-container {
|
|
||||||
width: 100%;
|
|
||||||
max-width: 380px;
|
|
||||||
padding: 2rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
gap: 0.75rem;
|
|
||||||
margin-bottom: 2.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo svg {
|
|
||||||
width: 40px;
|
|
||||||
height: 40px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo span {
|
|
||||||
font-size: 1.5rem;
|
|
||||||
font-weight: 600;
|
|
||||||
letter-spacing: -0.02em;
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn {
|
|
||||||
width: 100%;
|
|
||||||
padding: 0.75rem 1rem;
|
|
||||||
border: 1px solid #2a2a2a;
|
|
||||||
border-radius: 8px;
|
|
||||||
background: #151515;
|
|
||||||
color: #e0e0e0;
|
|
||||||
font-size: 0.925rem;
|
|
||||||
font-family: inherit;
|
|
||||||
cursor: pointer;
|
|
||||||
transition:
|
|
||||||
background 0.15s,
|
|
||||||
border-color 0.15s;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
gap: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn:hover {
|
|
||||||
background: #1e1e1e;
|
|
||||||
border-color: #3a3a3a;
|
|
||||||
}
|
|
||||||
.btn:disabled {
|
|
||||||
opacity: 0.5;
|
|
||||||
cursor: not-allowed;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-primary {
|
|
||||||
background: #fff;
|
|
||||||
color: #0a0a0a;
|
|
||||||
border-color: #fff;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-primary:hover {
|
|
||||||
background: #e0e0e0;
|
|
||||||
border-color: #e0e0e0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.divider {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 1rem;
|
|
||||||
margin: 1.5rem 0;
|
|
||||||
color: #555;
|
|
||||||
font-size: 0.8rem;
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.05em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.divider::before,
|
|
||||||
.divider::after {
|
|
||||||
content: '';
|
|
||||||
flex: 1;
|
|
||||||
height: 1px;
|
|
||||||
background: #2a2a2a;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-group {
|
|
||||||
margin-bottom: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-group input {
|
|
||||||
width: 100%;
|
|
||||||
padding: 0.75rem 1rem;
|
|
||||||
border: 1px solid #2a2a2a;
|
|
||||||
border-radius: 8px;
|
|
||||||
background: #151515;
|
|
||||||
color: #e0e0e0;
|
|
||||||
font-size: 0.925rem;
|
|
||||||
font-family: inherit;
|
|
||||||
outline: none;
|
|
||||||
transition: border-color 0.15s;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-group input:focus {
|
|
||||||
border-color: #555;
|
|
||||||
}
|
|
||||||
|
|
||||||
.error-msg {
|
|
||||||
background: #1a0000;
|
|
||||||
border: 1px solid #3a1111;
|
|
||||||
color: #ff6b6b;
|
|
||||||
padding: 0.75rem 1rem;
|
|
||||||
border-radius: 8px;
|
|
||||||
font-size: 0.85rem;
|
|
||||||
margin-bottom: 1rem;
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.spinner {
|
|
||||||
width: 18px;
|
|
||||||
height: 18px;
|
|
||||||
border: 2px solid transparent;
|
|
||||||
border-top-color: currentColor;
|
|
||||||
border-radius: 50%;
|
|
||||||
animation: spin 0.6s linear infinite;
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes spin {
|
|
||||||
to {
|
|
||||||
transform: rotate(360deg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.google-icon {
|
|
||||||
width: 18px;
|
|
||||||
height: 18px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="login-container">
|
|
||||||
<div class="logo">
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200" viewBox="14.75 14.75 70.5 70.5">
|
|
||||||
<g fill="white">
|
|
||||||
<path
|
|
||||||
d="M38.25 14.75H85.25V61.75H61.75V38.25H38.25ZM14.75 38.25H38.25V61.75H61.75V85.25H14.75Z"
|
|
||||||
/>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
||||||
<span>Monochrome</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="error" class="error-msg"></div>
|
|
||||||
|
|
||||||
<button id="google-btn" class="btn" onclick="googleSignIn()" style="display: none">
|
|
||||||
<svg class="google-icon" viewBox="0 0 24 24">
|
|
||||||
<path
|
|
||||||
fill="#4285F4"
|
|
||||||
d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z"
|
|
||||||
/>
|
|
||||||
<path
|
|
||||||
fill="#34A853"
|
|
||||||
d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"
|
|
||||||
/>
|
|
||||||
<path
|
|
||||||
fill="#FBBC05"
|
|
||||||
d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"
|
|
||||||
/>
|
|
||||||
<path
|
|
||||||
fill="#EA4335"
|
|
||||||
d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
Sign in with Google
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<div id="divider" class="divider" style="display: none">or</div>
|
|
||||||
|
|
||||||
<form id="email-form" onsubmit="emailAuth(event)" style="display: none">
|
|
||||||
<div class="form-group">
|
|
||||||
<input type="email" id="email" placeholder="Email" required autocomplete="email" />
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<input
|
|
||||||
type="password"
|
|
||||||
id="password"
|
|
||||||
placeholder="Password"
|
|
||||||
required
|
|
||||||
autocomplete="current-password"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<button type="submit" id="email-btn" class="btn btn-primary">
|
|
||||||
<span id="email-btn-text">Sign In</span>
|
|
||||||
<span id="email-btn-spinner" class="spinner"></span>
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script type="module">
|
|
||||||
import { initializeApp } from 'https://www.gstatic.com/firebasejs/10.7.1/firebase-app.js';
|
|
||||||
import {
|
|
||||||
getAuth,
|
|
||||||
GoogleAuthProvider,
|
|
||||||
signInWithPopup,
|
|
||||||
signInWithEmailAndPassword,
|
|
||||||
} from 'https://www.gstatic.com/firebasejs/10.7.1/firebase-auth.js';
|
|
||||||
|
|
||||||
const STORAGE_KEY = 'monochrome-firebase-config';
|
|
||||||
const DEFAULT_CONFIG = {
|
|
||||||
apiKey: 'AIzaSyDPU-unAjuLtQJt4IkGS5faG50UCF7lYyA',
|
|
||||||
authDomain: 'monochrome-database.firebaseapp.com',
|
|
||||||
projectId: 'monochrome-database',
|
|
||||||
storageBucket: 'monochrome-database.firebasestorage.app',
|
|
||||||
messagingSenderId: '895657412760',
|
|
||||||
appId: '1:895657412760:web:e81c5044c7f4e9b799e8ed',
|
|
||||||
};
|
|
||||||
|
|
||||||
// Check for setup_firebase hash import
|
|
||||||
const hash = window.location.hash;
|
|
||||||
if (hash.startsWith('#setup_firebase=')) {
|
|
||||||
try {
|
|
||||||
const encoded = hash.split('#setup_firebase=')[1];
|
|
||||||
const config = JSON.parse(atob(encoded));
|
|
||||||
if (config.apiKey && config.authDomain) {
|
|
||||||
localStorage.setItem(STORAGE_KEY, JSON.stringify(config));
|
|
||||||
window.history.replaceState(null, null, '/login');
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.warn('Failed to import Firebase config from hash:', e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let storedConfig = null;
|
|
||||||
try {
|
|
||||||
const raw = localStorage.getItem(STORAGE_KEY);
|
|
||||||
if (raw) storedConfig = JSON.parse(raw);
|
|
||||||
} catch (_) {}
|
|
||||||
|
|
||||||
// Priority: server-injected env > localStorage > hash-imported > default
|
|
||||||
const firebaseConfig = window.__FIREBASE_CONFIG__ || storedConfig || DEFAULT_CONFIG;
|
|
||||||
// Sync to localStorage so the app's config.js picks up the same project
|
|
||||||
if (window.__FIREBASE_CONFIG__ && !storedConfig) {
|
|
||||||
localStorage.setItem(STORAGE_KEY, JSON.stringify(firebaseConfig));
|
|
||||||
}
|
|
||||||
const fbApp = initializeApp(firebaseConfig);
|
|
||||||
const auth = getAuth(fbApp);
|
|
||||||
const provider = new GoogleAuthProvider();
|
|
||||||
|
|
||||||
function showError(msg) {
|
|
||||||
const el = document.getElementById('error');
|
|
||||||
el.textContent = msg;
|
|
||||||
el.style.display = 'block';
|
|
||||||
}
|
|
||||||
|
|
||||||
function hideError() {
|
|
||||||
document.getElementById('error').style.display = 'none';
|
|
||||||
}
|
|
||||||
|
|
||||||
const googleBtn = document.getElementById('google-btn');
|
|
||||||
const emailForm = document.getElementById('email-form');
|
|
||||||
const divider = document.getElementById('divider');
|
|
||||||
const providerState = {
|
|
||||||
google: true,
|
|
||||||
password: true,
|
|
||||||
};
|
|
||||||
const providerConfig = window.__AUTH_PROVIDERS__ || {};
|
|
||||||
if (typeof providerConfig.google === 'boolean') providerState.google = providerConfig.google;
|
|
||||||
if (typeof providerConfig.password === 'boolean') providerState.password = providerConfig.password;
|
|
||||||
|
|
||||||
const NO_PROVIDER_MESSAGE = 'No sign-in providers are enabled for this Firebase project.';
|
|
||||||
|
|
||||||
function renderProviders() {
|
|
||||||
if (googleBtn) googleBtn.style.display = providerState.google ? '' : 'none';
|
|
||||||
if (emailForm) emailForm.style.display = providerState.password ? '' : 'none';
|
|
||||||
if (divider) divider.style.display = providerState.google && providerState.password ? '' : 'none';
|
|
||||||
if (!providerState.google && !providerState.password) {
|
|
||||||
showError(NO_PROVIDER_MESSAGE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
renderProviders();
|
|
||||||
|
|
||||||
function setLoading(loading) {
|
|
||||||
document.getElementById('google-btn').disabled = loading;
|
|
||||||
document.getElementById('email-btn').disabled = loading;
|
|
||||||
document.getElementById('email-btn-text').style.display = loading ? 'none' : 'inline';
|
|
||||||
document.getElementById('email-btn-spinner').style.display = loading ? 'inline-block' : 'none';
|
|
||||||
}
|
|
||||||
|
|
||||||
async function sendTokenToServer(user) {
|
|
||||||
const token = await user.getIdToken();
|
|
||||||
const res = await fetch('/api/auth/login', {
|
|
||||||
method: 'POST',
|
|
||||||
headers: { 'Content-Type': 'application/json' },
|
|
||||||
body: JSON.stringify({ token }),
|
|
||||||
});
|
|
||||||
if (!res.ok) {
|
|
||||||
const data = await res.json().catch(() => ({}));
|
|
||||||
throw new Error(data.error || 'Server authentication failed');
|
|
||||||
}
|
|
||||||
window.location.href = '/';
|
|
||||||
}
|
|
||||||
|
|
||||||
window.googleSignIn = async function () {
|
|
||||||
hideError();
|
|
||||||
setLoading(true);
|
|
||||||
try {
|
|
||||||
const result = await signInWithPopup(auth, provider);
|
|
||||||
await sendTokenToServer(result.user);
|
|
||||||
} catch (err) {
|
|
||||||
if (err.code !== 'auth/popup-closed-by-user') {
|
|
||||||
showError(err.message);
|
|
||||||
}
|
|
||||||
setLoading(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
window.emailAuth = async function (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
hideError();
|
|
||||||
setLoading(true);
|
|
||||||
|
|
||||||
const email = document.getElementById('email').value;
|
|
||||||
const password = document.getElementById('password').value;
|
|
||||||
|
|
||||||
try {
|
|
||||||
const result = await signInWithEmailAndPassword(auth, email, password);
|
|
||||||
await sendTokenToServer(result.user);
|
|
||||||
} catch (err) {
|
|
||||||
showError(err.message);
|
|
||||||
setLoading(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
240
public/reset-password.html
Normal file
240
public/reset-password.html
Normal file
|
|
@ -0,0 +1,240 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>Reset Password</title>
|
||||||
|
<style>
|
||||||
|
*,
|
||||||
|
*::before,
|
||||||
|
*::after {
|
||||||
|
box-sizing: border-box;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-family:
|
||||||
|
'Inter',
|
||||||
|
-apple-system,
|
||||||
|
BlinkMacSystemFont,
|
||||||
|
'Segoe UI',
|
||||||
|
Roboto,
|
||||||
|
sans-serif;
|
||||||
|
background: #0a0a0a;
|
||||||
|
color: #e0e0e0;
|
||||||
|
min-height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 380px;
|
||||||
|
padding: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
font-weight: 600;
|
||||||
|
letter-spacing: -0.02em;
|
||||||
|
color: #fff;
|
||||||
|
text-align: center;
|
||||||
|
margin-bottom: 2.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn {
|
||||||
|
width: 100%;
|
||||||
|
padding: 0.75rem 1rem;
|
||||||
|
border: 1px solid #2a2a2a;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: #151515;
|
||||||
|
color: #e0e0e0;
|
||||||
|
font-size: 0.925rem;
|
||||||
|
font-family: inherit;
|
||||||
|
cursor: pointer;
|
||||||
|
transition:
|
||||||
|
background 0.15s,
|
||||||
|
border-color 0.15s;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn:hover {
|
||||||
|
background: #1e1e1e;
|
||||||
|
border-color: #3a3a3a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn:disabled {
|
||||||
|
opacity: 0.5;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary {
|
||||||
|
background: #fff;
|
||||||
|
color: #0a0a0a;
|
||||||
|
border-color: #fff;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary:hover {
|
||||||
|
background: #e0e0e0;
|
||||||
|
border-color: #e0e0e0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-group {
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-group input {
|
||||||
|
width: 100%;
|
||||||
|
padding: 0.75rem 1rem;
|
||||||
|
border: 1px solid #2a2a2a;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: #151515;
|
||||||
|
color: #e0e0e0;
|
||||||
|
font-size: 0.925rem;
|
||||||
|
font-family: inherit;
|
||||||
|
outline: none;
|
||||||
|
transition: border-color 0.15s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-group input:focus {
|
||||||
|
border-color: #555;
|
||||||
|
}
|
||||||
|
|
||||||
|
.message {
|
||||||
|
padding: 0.75rem 1rem;
|
||||||
|
border-radius: 8px;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-msg {
|
||||||
|
background: #1a0000;
|
||||||
|
border: 1px solid #3a1111;
|
||||||
|
color: #ff6b6b;
|
||||||
|
}
|
||||||
|
|
||||||
|
.success-msg {
|
||||||
|
background: #001a00;
|
||||||
|
border: 1px solid #113a11;
|
||||||
|
color: #6bff6b;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spinner {
|
||||||
|
width: 18px;
|
||||||
|
height: 18px;
|
||||||
|
border: 2px solid transparent;
|
||||||
|
border-top-color: currentColor;
|
||||||
|
border-radius: 50%;
|
||||||
|
animation: spin 0.6s linear infinite;
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes spin {
|
||||||
|
to {
|
||||||
|
transform: rotate(360deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<h1 class="title">Reset your Monochrome password</h1>
|
||||||
|
|
||||||
|
<div id="error" class="message error-msg"></div>
|
||||||
|
<div id="success" class="message success-msg"></div>
|
||||||
|
|
||||||
|
<form id="reset-form">
|
||||||
|
<div class="form-group">
|
||||||
|
<input type="password" id="password" placeholder="New Password" required minlength="8" />
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<input
|
||||||
|
type="password"
|
||||||
|
id="password-confirm"
|
||||||
|
placeholder="Confirm New Password"
|
||||||
|
required
|
||||||
|
minlength="8"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<button type="submit" id="reset-btn" class="btn btn-primary">
|
||||||
|
<span id="reset-btn-text">Reset Password</span>
|
||||||
|
<span id="reset-btn-spinner" class="spinner"></span>
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="module">
|
||||||
|
import { Client, Account } from 'appwrite';
|
||||||
|
|
||||||
|
const getEndpoint = () => {
|
||||||
|
const hostname = window.location.hostname;
|
||||||
|
if (hostname.endsWith('monochrome.tf') || hostname === 'monochrome.tf') {
|
||||||
|
return 'https://auth.monochrome.tf/v1';
|
||||||
|
}
|
||||||
|
return 'https://auth.samidy.com/v1';
|
||||||
|
};
|
||||||
|
|
||||||
|
const client = new Client().setEndpoint(getEndpoint()).setProject('auth-for-monochrome');
|
||||||
|
const account = new Account(client);
|
||||||
|
|
||||||
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
|
const userId = urlParams.get('userId');
|
||||||
|
const secret = urlParams.get('secret');
|
||||||
|
|
||||||
|
const errorEl = document.getElementById('error');
|
||||||
|
const successEl = document.getElementById('success');
|
||||||
|
const form = document.getElementById('reset-form');
|
||||||
|
const btn = document.getElementById('reset-btn');
|
||||||
|
const btnText = document.getElementById('reset-btn-text');
|
||||||
|
const spinner = document.getElementById('reset-btn-spinner');
|
||||||
|
|
||||||
|
if (!userId || !secret) {
|
||||||
|
errorEl.textContent = 'Invalid or missing password reset link.';
|
||||||
|
errorEl.style.display = 'block';
|
||||||
|
form.style.display = 'none';
|
||||||
|
}
|
||||||
|
|
||||||
|
form.addEventListener('submit', async (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
errorEl.style.display = 'none';
|
||||||
|
successEl.style.display = 'none';
|
||||||
|
|
||||||
|
const password = document.getElementById('password').value;
|
||||||
|
const passwordConfirm = document.getElementById('password-confirm').value;
|
||||||
|
|
||||||
|
if (password !== passwordConfirm) {
|
||||||
|
errorEl.textContent = 'Passwords do not match.';
|
||||||
|
errorEl.style.display = 'block';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
btn.disabled = true;
|
||||||
|
btnText.style.display = 'none';
|
||||||
|
spinner.style.display = 'inline-block';
|
||||||
|
|
||||||
|
try {
|
||||||
|
await account.updateRecovery(userId, secret, password, passwordConfirm);
|
||||||
|
successEl.textContent = 'Password reset successfully. Redirecting...';
|
||||||
|
successEl.style.display = 'block';
|
||||||
|
form.style.display = 'none';
|
||||||
|
setTimeout(() => {
|
||||||
|
window.location.href = '/';
|
||||||
|
}, 3000);
|
||||||
|
} catch (err) {
|
||||||
|
errorEl.textContent = err.message || 'Failed to reset password.';
|
||||||
|
errorEl.style.display = 'block';
|
||||||
|
btn.disabled = false;
|
||||||
|
btnText.style.display = 'inline';
|
||||||
|
spinner.style.display = 'none';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Reference in a new issue