-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathauth.html
More file actions
215 lines (187 loc) · 5.38 KB
/
auth.html
File metadata and controls
215 lines (187 loc) · 5.38 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Login to Chatbot</title>
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #4a6fa5 0%, #3a5a8a 100%);
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.login-container {
background-color: #4a6fa5;
padding: 30px;
border-radius: 12px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
border: 2px solid black;
width: 300px;
}
input {
width: 90%;
padding: 10px 14px;
margin-bottom: 15px;
font-size: 1rem;
border: 2px solid #000000;
border-radius: 6px;
background-color: #fdfdfd;
transition: all 0.3s ease;
}
input::placeholder {
color: #888;
opacity: 0.7;
}
input:focus {
outline: none;
border-color: #4a90e2;
background-color: #fff;
box-shadow: 0 0 0 4px rgba(74, 144, 226, 0.2);
}
input:hover {
border-color: #4a90e2;
}
.button-row {
display: flex;
justify-content: center;
gap: 20px;
}
.button-row button {
width: 40%;
text-align: center;
padding: 5px;
background: #4a90e2;
color: white;
border: none;
border-radius: 6px;
border: #ffffff 3px solid;
cursor: pointer;
}
button:hover {
background: #000000;
}
.link {
text-align: center;
margin-top: 10px;
}
.link a {
margin-right: 17px;
text-decoration: none;
color: white;
}
.google-button {
display: flex;
align-items: center;
justify-content: center;
background-color: #ffffff;
color: #444;
border: 2px solid #ccc;
border-radius: 6px;
padding: 10px 14px;
margin-top: 20px;
cursor: pointer;
font-size: 1rem;
font-weight: 500;
transition: background-color 0.3s ease, box-shadow 0.3s ease;
}
.google-button img {
margin-right: 10px;
}
.google-button:hover {
background-color: #f5f5f5;
box-shadow: 0 0 0 4px rgba(66, 133, 244, 0.2);
}
h2 {
text-align: center;
color: #fff9f9;
margin-bottom: 10px;
}
</style>
</head>
<body>
<div class="login-container">
<h2>Login</h2>
<input type="email" id="email" placeholder="Email" />
<input type="password" id="password" placeholder="Password" />
<div class="button-row">
<button onclick="login()">Login</button>
<button onclick="signup()">Sign Up</button>
</div>
<div class="google-button" onclick="googleSignIn()">
<img src="https://img.icons8.com/color/16/000000/google-logo.png" alt="Google Logo" />
<span>Sign in with Google</span>
</div>
<div class="link">
<a href="#">Forgot Password?</a>
</div>
</div>
<!-- Firebase SDK -->
<script src="https://www.gstatic.com/firebasejs/10.4.0/firebase-app-compat.js"></script>
<script src="https://www.gstatic.com/firebasejs/10.4.0/firebase-auth-compat.js"></script>
<script>
// Firebase config
const firebaseConfig = {
apiKey: "AIzaSyCVvaqJeppdqoL8lVM3rOdYlnqzZ3LmVsI",
authDomain: "chatbot-fdb19.firebaseapp.com",
projectId: "chatbot-fdb19",
storageBucket: "chatbot-fdb19.appspot.com",
messagingSenderId: "499513063427",
appId: "1:499513063427:web:b971d14bdb128fcc11f636",
measurementId: "G-9V7PKYR92K"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
const auth = firebase.auth();
function login() {
const email = document.getElementById('email').value.trim();
const password = document.getElementById('password').value.trim();
auth.signInWithEmailAndPassword(email, password)
.then(() => {
window.location.href = "chatbot.html";
})
.catch(err => alert("Login Failed: " + err.message));
}
function signup() {
const email = document.getElementById('email').value.trim();
const password = document.getElementById('password').value.trim();
if (!email || !password) {
alert("Please enter both email and password.");
return;
}
if (password.length < 6) {
alert("Password must be at least 6 characters long.");
return;
}
auth.createUserWithEmailAndPassword(email, password)
.then(() => {
alert("Sign up successful! Now login.");
})
.catch(err => {
if (err.code === 'auth/email-already-in-use') {
alert("This email is already registered. Please log in.");
} else if (err.code === 'auth/invalid-email') {
alert("Invalid email format.");
} else {
alert("Signup Failed: " + err.message);
}
});
}
function googleSignIn() {
const provider = new firebase.auth.GoogleAuthProvider();
auth.signInWithPopup(provider)
.then(result => {
const user = result.user;
console.log("Google Sign-In Success:", user.email);
window.location.href = "chatbot.html";
})
.catch(error => {
console.error("Google Sign-In Error:", error);
alert("Google Sign-In Failed: " + error.message);
});
}
</script>
</body>
</html>