UniversityAI / forgot-password.html
Alsmwal's picture
Update forgot-password.html
60ac85c verified
Raw
History Blame
11.4 kB
<!--forget pass -->
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Forget the password- University AI</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
:root {
--olive-light: #3A662A;
--bg-light: #FFFFFF;
--text-light: #2C2C2C;
--bg-dark: #1A1A1A;
--text-dark: #F5F5F5;
--card-light: #F8F9FA;
--card-dark: #2D2D2D;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.3s ease;
}
body.light-mode {
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
color: var(--text-light);
}
body.dark-mode {
background: linear-gradient(135deg, #1a1a1a 0%, #2d3748 100%);
color: var(--text-dark);
}
.container {
width: 100%;
max-width: 450px;
padding: 20px;
}
.card {
padding: 40px;
border-radius: 15px;
box-shadow: 0 10px 40px rgba(0,0,0,0.1);
transition: all 0.3s ease;
}
.light-mode .card {
background: white;
}
.dark-mode .card {
background: var(--card-dark);
}
.header {
text-align: center;
margin-bottom: 30px;
}
.logo {
font-size: 48px;
margin-bottom: 10px;
}
h1 {
font-size: 28px;
margin-bottom: 10px;
color: var(--olive-light);
}
.subtitle {
opacity: 0.7;
font-size: 14px;
line-height: 1.6;
}
.form-group {
margin-bottom: 20px;
}
label {
display: block;
margin-bottom: 8px;
font-weight: 500;
}
input {
width: 100%;
padding: 12px 15px;
border-radius: 8px;
border: 2px solid #e0e0e0;
font-size: 16px;
transition: all 0.3s ease;
}
.light-mode input {
background: white;
color: var(--text-light);
}
.dark-mode input {
background: var(--bg-dark);
color: var(--text-dark);
border-color: #444;
}
input:focus {
outline: none;
border-color: var(--olive-light);
}
.btn {
width: 100%;
padding: 14px;
border: none;
border-radius: 8px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
background: var(--olive-light);
color: white;
}
.btn:hover {
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(58, 102, 42, 0.4);
}
.btn:disabled {
opacity: 0.6;
cursor: not-allowed;
transform: none;
}
.alert {
padding: 12px;
border-radius: 8px;
margin-bottom: 20px;
display: none;
}
.alert.error {
background: #fee;
color: #c33;
border: 1px solid #fcc;
}
.alert.success {
background: #efe;
color: #3c3;
border: 1px solid #cfc;
}
.alert.show {
display: block;
}
.links {
text-align: center;
margin-top: 20px;
font-size: 14px;
}
.links a {
color: var(--olive-light);
text-decoration: none;
font-weight: 500;
}
.links a:hover {
text-decoration: underline;
}
.divider {
margin: 20px 0;
text-align: center;
opacity: 0.5;
}
.loading {
display: none;
text-align: center;
margin-top: 10px;
}
.loading.show {
display: block;
}
/* Top Bar with Theme Toggle */
.top-bar {
position: fixed;
top: 0;
left: 0;
right: 0;
padding: 15px 20px;
display: flex;
justify-content: space-between;
align-items: center;
z-index: 1000;
}
.light-mode .top-bar {
background: rgba(255,255,255,0.9);
}
.dark-mode .top-bar {
background: rgba(45,45,45,0.9);
}
.theme-toggle {
width: 50px;
height: 26px;
background: var(--olive-light);
border-radius: 13px;
position: relative;
cursor: pointer;
transition: all 0.3s ease;
}
.theme-toggle::after {
content: '☀️';
position: absolute;
top: 3px;
left: 3px;
width: 20px;
height: 20px;
background: white;
border-radius: 50%;
transition: all 0.3s ease;
display: flex;
align-items: center;
justify-content: center;
font-size: 12px;
}
.dark-mode .theme-toggle::after {
content: '🌙';
left: 27px;
}
.back-home {
padding: 10px 20px;
background: var(--olive-light);
color: white;
text-decoration: none;
border-radius: 8px;
font-size: 14px;
transition: all 0.3s ease;
}
.back-home:hover {
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(58, 102, 42, 0.4);
}
@media (max-width: 768px) {
body {
padding-top: 60px;
}
.top-bar {
padding: 10px 15px;
}
}
</style>
</head>
<body class="light-mode">
<div class="top-bar">
<a href="index.html" class="back-home">🏠 Home</a>
<div class="theme-toggle" onclick="toggleTheme()"></div>
</div>
<div class="container">
<div class="card">
<div class="header">
<div class="logo">🔑</div>
<h1>Forgot Password</h1>
<p class="subtitle">Don't worry! Enter your email and we will send you a code to reset your password
</p>
</div>
<div id="alert" class="alert"></div>
<!-- ✅ FIXED: Changed form to div -->
<div id="forgotForm">
<div class="form-group">
<label for="email">Email </label>
<input
type="email"
id="email"
name="email"
required
placeholder="example@university.edu"
>
</div>
<!-- ✅ FIXED: Changed type to button and added onclick -->
<button type="button" class="btn" id="sendBtn" onclick="handleForgot()">
Send Reset Code
</button>
<div class="loading" id="loading">
<p>Sending...</p>
</div>
</div>
<div class="divider">───────</div>
<div class="links">
<p>Remember your passwprd ? <a href="login.html">Login </a></p>
<p style="margin-top: 10px;">
Don't have account ?<a href="register.html">Create account</a>
</p>
</div>
</div>
</div>
<script>
const API_URL = '';
// Theme Toggle
function toggleTheme() {
const body = document.body;
if (body.classList.contains('light-mode')) {
body.classList.remove('light-mode');
body.classList.add('dark-mode');
localStorage.setItem('theme', 'dark');
} else {
body.classList.remove('dark-mode');
body.classList.add('light-mode');
localStorage.setItem('theme', 'light');
}
}
// Load saved theme
document.addEventListener("DOMContentLoaded", () => {
const savedTheme = localStorage.getItem('theme') || 'light';
document.body.classList.remove("light-mode", "dark-mode");
document.body.classList.add(savedTheme + "-mode");
});
// عرض رسالة
function showAlert(message, type = 'success') {
const alert = document.getElementById('alert');
alert.textContent = message;
alert.className = `alert ${type} show`;
setTimeout(() => {
alert.classList.remove('show');
}, 8000);
}
// معالجة الطلب
// ✅ FIXED: Replaced event listener with direct function
async function handleForgot() {
const email = document.getElementById('email').value;
const sendBtn = document.getElementById('sendBtn');
const loading = document.getElementById('loading');
sendBtn.disabled = true;
loading.classList.add('show');
try {
const response = await fetch(`${API_URL}/auth/forgot-password`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
email: email
})
});
const data = await response.json();
if (response.ok) {
showAlert(
'✅ If the email is registered, a code has been sent. Redirecting...',
'success'
);
setTimeout(() => {
window.location.href = `reset-password.html?email=${encodeURIComponent(email)}`;
}, 1500);
} else {
// To prevent email enumeration, we show a success message even on failure.
showAlert('✅ If the email is registered, a code has been sent. Redirecting...', 'success');
setTimeout(() => {
window.location.href = `reset-password.html?email=${encodeURIComponent(email)}`;
}, 1500);
}
} catch (error) {
console.error('Forgot password error:', error);
showAlert('There was an error connecting to the server. Please try again..', 'error');
} finally {
sendBtn.disabled = false;
loading.classList.remove('show');
}
}
</script>
</body>
</html>