Spaces:
Running
Running
Update app.js
Browse files
app.js
CHANGED
|
@@ -1212,6 +1212,21 @@ on('auth-toggle-mode', 'click', () => {
|
|
| 1212 |
if (authToggleMode) authToggleMode.textContent = isAuthRegister ? "Already have an account? Sign In" : "Need an account? Register";
|
| 1213 |
});
|
| 1214 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1215 |
on('auth-submit-btn', 'click', async () => {
|
| 1216 |
if (!auth) return;
|
| 1217 |
const email = authEmail.value.trim(), pass = authPassword.value.trim();
|
|
@@ -1224,9 +1239,22 @@ on('auth-submit-btn', 'click', async () => {
|
|
| 1224 |
return;
|
| 1225 |
}
|
| 1226 |
try {
|
| 1227 |
-
if (isAuthRegister)
|
| 1228 |
-
|
| 1229 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1230 |
} catch (err) {
|
| 1231 |
if (authError) {
|
| 1232 |
authError.textContent = err.message.replace("Firebase: ", "");
|
|
|
|
| 1212 |
if (authToggleMode) authToggleMode.textContent = isAuthRegister ? "Already have an account? Sign In" : "Need an account? Register";
|
| 1213 |
});
|
| 1214 |
|
| 1215 |
+
// Google Auth
|
| 1216 |
+
on('auth-google-btn', 'click', async () => {
|
| 1217 |
+
if (!auth) return;
|
| 1218 |
+
try {
|
| 1219 |
+
const provider = new firebase.auth.GoogleAuthProvider();
|
| 1220 |
+
await auth.signInWithPopup(provider);
|
| 1221 |
+
if (authModal) authModal.classList.add('hidden');
|
| 1222 |
+
} catch (err) {
|
| 1223 |
+
if (authError) {
|
| 1224 |
+
authError.textContent = err.message.replace("Firebase: ", "");
|
| 1225 |
+
authError.classList.remove('hidden');
|
| 1226 |
+
}
|
| 1227 |
+
}
|
| 1228 |
+
});
|
| 1229 |
+
|
| 1230 |
on('auth-submit-btn', 'click', async () => {
|
| 1231 |
if (!auth) return;
|
| 1232 |
const email = authEmail.value.trim(), pass = authPassword.value.trim();
|
|
|
|
| 1239 |
return;
|
| 1240 |
}
|
| 1241 |
try {
|
| 1242 |
+
if (isAuthRegister) {
|
| 1243 |
+
// Create account & dispatch verification link
|
| 1244 |
+
const cred = await auth.createUserWithEmailAndPassword(email, pass);
|
| 1245 |
+
await cred.user.sendEmailVerification();
|
| 1246 |
+
await auth.signOut(); // Kick out until verified
|
| 1247 |
+
alert("Verification email sent! Click the link in your inbox before logging in.");
|
| 1248 |
+
if (authModal) authModal.classList.add('hidden');
|
| 1249 |
+
} else {
|
| 1250 |
+
// Sign in & check verification status
|
| 1251 |
+
const cred = await auth.signInWithEmailAndPassword(email, pass);
|
| 1252 |
+
if (!cred.user.emailVerified) {
|
| 1253 |
+
await auth.signOut();
|
| 1254 |
+
throw new Error("Please verify your email address first. Check your inbox or spam folder.");
|
| 1255 |
+
}
|
| 1256 |
+
if (authModal) authModal.classList.add('hidden');
|
| 1257 |
+
}
|
| 1258 |
} catch (err) {
|
| 1259 |
if (authError) {
|
| 1260 |
authError.textContent = err.message.replace("Firebase: ", "");
|