-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreset-password.html
More file actions
125 lines (114 loc) · 5.06 KB
/
reset-password.html
File metadata and controls
125 lines (114 loc) · 5.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Visualizing Math</title>
<link rel="stylesheet" href="style.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@100;200;300;400;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.1/css/all.min.css" integrity="sha512-5Hs3dF2AEPkpNAR7UiOHba+lRSJNeM2ECkwxUIxC1Q/FLycGTbNapWXB4tP889k5T5Ju8fs4b1P5z/iB4nMfSQ==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href='https://unpkg.com/boxicons@2.1.4/css/boxicons.min.css' rel='stylesheet'>
</head>
<body>
<section class="sub-header">
<nav>
<a href="index.html"><img src="images/logo.png" alt="Logo"></a>
<div class="nav-links" id="navLinks">
<i class="fas fa-xmark" onclick="hideMenu()"></i>
<ul>
<li><a href="index.html">HOME</a></li>
<li><a href="about.html">ABOUT</a></li>
<li><a href="SignUp.html">SIGN UP</a></li>
<li id="login-nav"><a href="Login.html">LOG IN</a></li>
<li id="logout-nav" style="display: none;"><a href="#" onclick="logout()">LOG OUT</a></li>
<li><a href="Algebra.html">ALGEBRA</a></li>
<li><a href="Geometry.html">GEOMETRY</a></li>
</ul>
</div>
<i class="fas fa-bars" onclick="showMenu()"></i>
</nav>
<h1>Reset Password</h1>
</section>
<div class="wrapper">
<div class="form-box">
<div class="register-container">
<form id="reset-password-form">
<div class="input-box">
<input type="password" class="input-field" placeholder="New Password" id="new-password" required>
</div>
<div class="input-box">
<input type="submit" class="submit" value="Reset Password">
</div>
</form>
</div>
</div>
</div>
<!-- JavaScript for Toggle Menu and Form Submission -->
</script>
<script type="module">
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.10.0/firebase-app.js";
import { getAuth, verifyPasswordResetCode, confirmPasswordReset } from "https://www.gstatic.com/firebasejs/10.10.0/firebase-auth.js";
const firebaseConfig = {
apiKey: "AIzaSyAMPqEC7vmFh0Sm22KMmAVxaS_F7CI_YRM",
authDomain: "visualizing-math.firebaseapp.com",
projectId: "visualizing-math",
storageBucket: "visualizing-math.appspot.com",
messagingSenderId: "128503124502",
appId: "1:128503124502:web:a5a5c786244e25c0af9b37",
measurementId: "G-7LGGDVLGLP"
};
const app = initializeApp(firebaseConfig);
const auth = getAuth(app);
// Get reset code from URL
const urlParams = new URLSearchParams(window.location.search);
const oobCode = urlParams.get('oobCode');
if (!oobCode) {
alert("Missing reset code. Please use the link sent to your email.");
window.location.href = "Login.html";
}
const form = document.getElementById("reset-password-form");
form.addEventListener("submit", async (e) => {
e.preventDefault();
const newPassword = document.getElementById("new-password").value;
try {
await verifyPasswordResetCode(auth, oobCode); // Check code validity
await confirmPasswordReset(auth, oobCode, newPassword); // Reset password
alert("Password reset successful!");
window.location.href = "Login.html";
} catch (error) {
console.error("Error resetting password:", error);
alert("Failed to reset password: " + error.message);
}
});
</script>
<script>
// Toggle menu
var navLinks = document.getElementById("navLinks");
function showMenu() {
navLinks.style.right = "0";
}
function hideMenu() {
navLinks.style.right = "-200px";
}
</script>
<script>
// Check login status on page load
document.addEventListener("DOMContentLoaded", () => {
const token = localStorage.getItem('token') || sessionStorage.getItem('token');
if (token) {
document.getElementById("login-nav").style.display = "none";
document.getElementById("logout-nav").style.display = "inline-block";
}
});
// Logout function
function logout() {
localStorage.removeItem('token');
sessionStorage.removeItem('token');
alert("You have been logged out.");
window.location.href = 'Login.html'; // Redirect to Login page
}
</body>
</html>