-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemail.html
66 lines (62 loc) · 2.17 KB
/
email.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login Page</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="container">
<div class="image-section">
<div class="background"></div>
</div>
<div class="form-section">
<h1 id="h1">Loading...</h1>
<p id="p">Loading...</p>
</div>
<script type="module">
import {
initializeApp
} from 'https://www.gstatic.com/firebasejs/11.0.2/firebase-app.js';
import {
getAuth,
onAuthStateChanged,
sendEmailVerification
} from 'https://www.gstatic.com/firebasejs/11.0.2/firebase-auth.js';
const firebaseConfig = {
apiKey: "AIzaSyC4guPinRRwZ3AlBdeiZMbn4XKq6_-d1Bo",
authDomain: "auth-test-556c5.firebaseapp.com",
projectId: "auth-test-556c5",
storageBucket: "auth-test-556c5.firebasestorage.app",
messagingSenderId: "274619285634",
appId: "1:274619285634:web:d07e6c6d136041e23b749b"
};
const app = initializeApp(firebaseConfig);
const auth = getAuth();
const h1 = document.getElementById('h1');
const main = document.getElementById('p');
onAuthStateChanged(auth, (user) => {
if (user) {
if (!user.emailVerified) {
h1.innerText = 'Email Verification Required';
main.innerText = `A confirmation email has been sent to ${user.email}. Please verify your email.`;
sendEmailVerification(user)
.then(() => console.log('Verification email sent.'))
.catch((error) => console.error('Error sending email verification:', error));
} else {
h1.innerText = 'Authentication Complete';
main.innerText = `Hello, ${user.displayName || 'User'}!`;
}
} else {
h1.innerText = 'Not Logged In';
main.innerText = 'Please log in. Redirecting to login page...';
setTimeout(() => {
window.location.href = 'login'; // Replace with your login page URL
}, 3000);
}
});
</script>
</div>
</body>
</html>