-
Notifications
You must be signed in to change notification settings - Fork 1
/
login1.html
99 lines (88 loc) · 3.14 KB
/
login1.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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Modern Login Form | CodingStella</title>
<link rel='stylesheet' href='https://unpkg.com/boxicons@2.1.4/css/boxicons.min.css'>
<link rel='stylesheet' href='https://fonts.googleapis.com/css2?family=Poppins&display=swap'>
<link rel="stylesheet" type="text/css" href="login.css">
</head>
<body>
<div class="wrapper">
<div class="login_box">
<form id="login-form">
<div class="login-header">
<span>Login</span>
</div>
<div class="input_box">
<input type="text" id="email" class="input-field" required>
<label for="user" class="label">Email</label>
<i class="bx bx-user icon"></i>
</div>
<div class="input_box">
<input type="password" id="password" class="input-field" required>
<label for="pass" class="label">Password</label>
<i class="bx bx-lock-alt icon"></i>
</div>
<div class="remember-forgot">
<div class="remember-me">
<input type="checkbox" id="remember">
<label for="remember">Remember me</label>
</div>
<div class="forgot">
<a href="#">Forgot password?</a>
</div>
</div>
<div class="input_box">
<button type="submit" class="input-submit">Login</button>
</div>
<div class="register">
<span>Don't have an account? <a href="#">Register</a></span>
</div>
</form>
</div>
</div>
<!-- <script type="module" src="login.js"></script> -->
<script type="module">
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.0.0/firebase-app.js";
import { getAnalytics } from "https://www.gstatic.com/firebasejs/9.0.0/firebase-analytics.js";
import { getAuth } from "https://www.gstatic.com/firebasejs/9.0.0/firebase-auth.js";
document.getElementById('login-form').addEventListener('submit', (event) => {
event.preventDefault();
login();
});
const firebaseConfig = {
apiKey: "AIzaSyBZnn4RPMlAdECe6k4kgJTRUBflgR4hTEA",
authDomain: "travel-buddy-471e0.firebaseapp.com",
projectId: "travel-buddy-471e0",
storageBucket: "travel-buddy-471e0.appspot.com",
messagingSenderId: "785129601834",
appId: "1:785129601834:web:4a82e0e7c5fe4668983c53",
measurementId: "G-PMQWZR7Y8L"
};
const app = initializeApp(firebaseConfig);
const analytics = getAnalytics(app);
const auth = getAuth();
firebase.auth().onAuthStateChanged((user) => {
if (user) {
window.location.assign('/deep-home.html');
} else {
alert('user is not signed in');
}
});
function login() {
const email = document.getElementById('email').value;
const password = document.getElementById('password').value;
auth.signInWithEmailAndPassword(email, password)
.then((userCredential) => {
const user = userCredential.user;
console.log("User signed in:", user);
})
.catch((error) => {
const errorMessage = error.message;
console.log(errorMessage);
});
}
</script>
</body>
</html>