Skip to content

Commit 4cd8b98

Browse files
authored
Merge pull request #375 from Jatzz26/update_jatin
Corrected the signup page (sign in with Google) functionality
2 parents 270173c + 4aba3e3 commit 4cd8b98

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

staticfiles/mainfiles/signup/script.js

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -98,24 +98,26 @@ async function checkIfUserExists(email) {
9898
// Handle Google sign up
9999
googleSignUpButton.addEventListener("click", async () => {
100100
try {
101-
const provider = new GoogleAuthProvider();
102-
const result = await signInWithPopup(auth, provider);
103-
const user = result.user;
104-
105-
const userExists = await checkIfUserExists(user.email);
106-
if (userExists) {
107-
alert("This email is already registered with us. Signing in you.");
108-
window.location.href = "/login";
109-
return;
110-
}
111-
112-
localStorage.setItem("uid", user.uid);
113-
localStorage.setItem("email", user.email);
101+
const provider = new GoogleAuthProvider();
102+
const result = await signInWithPopup(auth, provider);
103+
const user = result.user;
104+
// console.log(user.email);
105+
106+
// Check if the email is already registered
107+
const userExists = await checkIfUserExists(user.email);
108+
if (userExists) {
109+
window.location.href = "/login ";
110+
return;
111+
}
114112

115-
await saveUserDataToFirestore(user.uid, user.displayName, user.email, user.phoneNumber);
113+
// Store user info in localStorage (consider security implications)
114+
localStorage.setItem("uid", user.uid);
115+
localStorage.setItem("email", user.email);
116+
localStorage.setItem("phonenumber", user.phoneNumber);
116117

117-
window.location.href = "/myaccount";
118-
} catch (error) {
119-
console.error("Error signing up with Google:", error.message);
120-
}
118+
// Redirect to home page
119+
window.location.href = "/";
120+
} catch (error) {
121+
console.log("Error Logging in with Google: ", error.message);
122+
}
121123
});

0 commit comments

Comments
 (0)