diff --git a/.firebase/hosting.ZGlzdA.cache b/.firebase/hosting.ZGlzdA.cache index e17e5e3..c9f8ef1 100644 --- a/.firebase/hosting.ZGlzdA.cache +++ b/.firebase/hosting.ZGlzdA.cache @@ -18,26 +18,26 @@ logo.svg,1702805755363,106fd0e0e25e62773089d32eafec6046eb8f0d1a196e632a72cdfd228 profile.png,1707892322036,3db19429a79553f09c0adebdb3d58cbb8699e45584f31fc73c55198c67ce3acf signin.svg,1686127288433,f60118db2a3203e28dc8285cf5d2dafbc799618ee6b2a4d0d3a63f36ba584c8e vite.svg,1680593882164,59ec4b6085a0cb1bf712a5e48dd5f35b08e34830d49c2026c18241be04e05d5a -index.html,1709456931479,d54f4de72169df7fbc9ac03a470d32e61f4f928fc802a1c55274e3a883625914 -assets/AdminDashboard-2115034d.js,1709456931467,3e598bcabd25892c19be7e09fd3da2c692dadd8a611552488678e22bfd114ddc -assets/ajax-loader-e7b44c86.gif,1709456931463,e9699a225e244ba8bb48532313e5c56a76fe08358c6dd684fb3234f2f63e7961 -assets/index-b139ad4f.css,1709456931465,2dc356270b9598957f0a0296e5c40d33d8b20a2317fcf5adf73ce509a267e241 -assets/HomePage-cf332abe.css,1709456931465,5c3dd8c3364bf3887a0ffc40025675bdc7ffd43701cdd2f5755bb601b3ffff59 -assets/MyProfile-408e5506.js,1709456931466,2823930fae99be3f4e3d9d9827984b6dd0428b0ebb457a395226d5058648d995 -assets/index.esm-db58b76b.js,1709456931465,d431edea8ad1056b9b4badaf75d1aabedfb66da020b9314c8e43ee142640202d -assets/OnBoardingForm-003df330.css,1709456931465,660482a0aeba2c167de6e80851bf186d6939e1209dc2150a0743831e8d5d4109 -assets/profile-610a26c1.js,1709456931466,bc6f4720dee2492391e413bd19b14e14498f0a856b5a325876e90bc5c3f830fc -assets/OnBoardingForm-1d45cd75.js,1709456931471,33100b3bb6ec366c02c7b92ad718cea4380f86efd195f4c1e7574b89a6d86b51 -assets/ProfileList-1e34a258.css,1709456931465,94d6f076540233e531ecca64bde431e73adb69f92a320e89633a9d9618618365 -assets/ProfileList-da937e87.js,1709456931467,9452a420a13876f51dad2eed11980942355112d95221d4e8173e7010bd0d3f71 -assets/SignIn-deeb1b75.js,1709456931467,343f6a4e590f70e6d2d57d9294da59fd66214f415e6dcbda0dcd723678b912ea -assets/SignIn-546af57c.css,1709456931465,4bb3288d1795822ccfa709d00c582eb82d54076ff675a8131eaef78ade317c7c -assets/SignUp-2fffacea.css,1709456931465,069a282e6dad21397c728a994b3e55f7993bf3be2acf3142d4a97a04b340c071 -assets/SignUp-4501ad0a.js,1709456931466,68f9ade9cb408305c50141a980c6ff801a45bfc08874dcf845f59af7025b7314 -assets/Test-ff9b7af4.js,1709456931466,da10fcf96aaa611de01e4b7c7b3e8865f3a8eb8b2b70d5e0e74b30b69bc5fe6f -assets/Team-a8f36299.js,1709456931466,e83afc7f81b2b12d8e640ff1dec3eef2658abb49dc807b0cb51ae4bececa2b62 -assets/slick-12459f22.svg,1709456931465,d00477d40ed40fa1dd3bdee27d9286804121b15fea83bae7d5415d902b055de0 -assets/UnauthorizedError-224673df.js,1709456931466,a730927f3398dc48f500ec30a276f1cbbc88fe791e19fd4c4c8b6650c8ff8718 -assets/UnderReview-1fc2efc2.js,1709456931465,21e7b39e3a48924afbaf2d62261ecd26622037419d423bc3879b2f837510ab0a -assets/HomePage-5ede1828.js,1709456931479,ebab1382e2c8f4319cac6cca2b6618473bcfac881703590ede8a23b795166f9a -assets/index-f267be31.js,1709456931480,912a5b3c8fa5dea72a40db05e9f52750234fda4a0e13dffcfe21caff91e4114f +index.html,1709482578232,cf75a692bb10c3b5365483d98bdb77ce5b0f9bfb1cc0ca68deca9cd93d835d28 +assets/AdminDashboard-8221f54b.js,1709482578226,2d62adbe28cec12f5f4b5092c3477520ce62726794bbb7cb2c950c95ce1e8a54 +assets/ajax-loader-e7b44c86.gif,1709482578225,e9699a225e244ba8bb48532313e5c56a76fe08358c6dd684fb3234f2f63e7961 +assets/HomePage-d05ed5a4.css,1709482578225,07ad2ebc60866a5a6370a2a0580b6ee880565d517322107971a97bb3927b4333 +assets/index-bc247fe3.css,1709482578225,83886c58cd522f875762604166d13c81f54874dde0db49074003cf70ef8934d5 +assets/index.esm-b27368d8.js,1709482578226,475c5f17c55edc4b35cef6a76cc44ddbdf5668a5703f885e3ea147a66742b538 +assets/MyProfile-dc49609e.js,1709482578226,775a396bdc12273e9268c2686a426ae4209a2e8b1fad81dfd899a334714796c8 +assets/OnBoardingForm-003df330.css,1709482578225,660482a0aeba2c167de6e80851bf186d6939e1209dc2150a0743831e8d5d4109 +assets/profile-84ca40f8.js,1709482578226,5c8a521802fe1f2794c636f4520bc9d00ffb4c79bd11c617a10b4bab5f560172 +assets/OnBoardingForm-54428542.js,1709482578226,4f99d2bff30e5f570e0173e487d885d1975844766659d85b26c52404971e45d8 +assets/ProfileList-1e34a258.css,1709482578225,94d6f076540233e531ecca64bde431e73adb69f92a320e89633a9d9618618365 +assets/SignIn-0f83d84f.js,1709482578226,b4dff7882d1b343f0f90e9693d001a10107a6de0a716af40dd25d357f570b2ad +assets/ProfileList-5512821a.js,1709482578227,e51191ee92bc32b0598d1899420417ea60c49bdd2be34293ea5ba65757f63036 +assets/SignIn-546af57c.css,1709482578225,4bb3288d1795822ccfa709d00c582eb82d54076ff675a8131eaef78ade317c7c +assets/SignUp-262a54aa.js,1709482578226,ed822d8903e4b3cf2cb5ac77ac7f817123866c8e902fd0f80864db56ac3e853c +assets/SignUp-2fffacea.css,1709482578225,069a282e6dad21397c728a994b3e55f7993bf3be2acf3142d4a97a04b340c071 +assets/slick-12459f22.svg,1709482578223,d00477d40ed40fa1dd3bdee27d9286804121b15fea83bae7d5415d902b055de0 +assets/Team-924e9a6b.js,1709482578226,fe2d33784eaa77f53c152a8ffcbade063ca591ccc4b13c72e57554e0bc8713c4 +assets/Test-85b99c15.js,1709482578226,4584e19bef46697dade31832c55fbe39d40e3067636985df1699ca26624a781a +assets/UnauthorizedError-3f1548dd.js,1709482578226,f595f024a07014bbdd1a8179adae5fc91d7df20aae3474567614584d42b484a5 +assets/UnderReview-26fe0c17.js,1709482578226,1237bf0884497368cc0c9cc0aa6c281c9faa7724c37c2f04325b5252c4fbb9e2 +assets/HomePage-db466994.js,1709482578232,5a7ffc3af0e25282a153a6021120f2d8d8a3ddf79937f4924e363ee34f75a746 +assets/index-47bfaaf6.js,1709482578234,e5cb1cb8d2bbf7c5a6a2a04c7d76971cb9075c2a6f7bae4fb0b9d0ab41f254fc diff --git a/src/components/Navbar.jsx b/src/components/Navbar.jsx index 2ce44fe..1b935a1 100644 --- a/src/components/Navbar.jsx +++ b/src/components/Navbar.jsx @@ -140,7 +140,17 @@ export const Navbar = () => {
Name | -Graduation Year | -Major | -Current Company | -LinkedIn ID | -PFP | -Actions | -|||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
{user.name} | -{user.email} | -{user.graduationYear} | -{user.major} | -{user.currentCompany} | -https://linkedin.com/in/{user.linkedin} | -- - | -- - - | +
Name | +Graduation Year | +Major | +Current Company | +LinkedIn ID | +PFP | +Actions |
---|
Current Company:{" "} - {profile.currentCompany?.length > 15 + {profile.currentCompany?.length > 20 ? profile.currentCompany.slice(0, 15) + "..." : profile.currentCompany} diff --git a/src/pages/SignIn.jsx b/src/pages/SignIn.jsx index d15b6e2..6c19d9f 100644 --- a/src/pages/SignIn.jsx +++ b/src/pages/SignIn.jsx @@ -1,10 +1,5 @@ import React, { useState } from "react"; -import { - getAuth, - signInWithEmailAndPassword, - fetchSignInMethodsForEmail, - signInWithPopup, -} from "firebase/auth"; +import { getAuth, signInWithPopup } from "firebase/auth"; import { auth, googleProvider, @@ -14,74 +9,38 @@ import { import { toast } from "react-toastify"; import "react-toastify/dist/ReactToastify.css"; import { useNavigate } from "react-router-dom"; -import { collection, getDocs, doc } from "firebase/firestore"; +import { collection, getDocs, doc, getDoc } from "firebase/firestore"; import "./SignIn.css"; -// Declare the variables here -let email, password; const SignIn = () => { const navigate = useNavigate(); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); - // const handleSignIn = async () => { - // if (email === "" || password === "") { - // toast.error("Please fill in all the fields"); - // return; - // } - - // const auth = getAuth(); - - // try { - // // Sign in the user with email and password - // await signInWithEmailAndPassword(auth, email, password); - - // // Get the user's UID - // const user = auth.currentUser; - - // // Reference to the Firestore collection - // const alumniCollection = collection(db, "alumni"); - - // // Get all documents in the "alumni" collection - // const querySnapshot = await getDocs(alumniCollection); - - // // Loop through each document - // querySnapshot.forEach(async (doc) => { - // // Check if the firebaseUID matches the current user's UID - // if (doc.data().firebaseUID === user.uid) { - // // If the user document is found, check the isVerified field - // const isVerified = doc.data().isVerified; - - // if (!isVerified) { - // // User is not verified, navigate to under review page - // navigate("/undereview"); - // } else { - // // User is verified, proceed with navigation - // navigate("/"); - // } + const checkUserExistence = async (email) => { + try { + const userEmailDocRef = doc(collection(db, "userEmails"), email); + const userEmailDoc = await getDoc(userEmailDocRef); - // // Exit the loop once the user document is found - // return; - // } - // }); + return userEmailDoc.exists(); + } catch (error) { + console.error("Error checking user existence:", error); + return true; // Assume existence to prevent unintentional sign-up + } + }; - // toast.success("Signed in successfully!"); - // } catch (error) { - // toast.error("Error signing in"); - // console.error(error); - // } - // }; const signInWithGitHub = async () => { try { const auth = getAuth(); const result = await signInWithPopup(auth, githubProvider); const user = result.user; - const signInMethods = await fetchSignInMethodsForEmail(auth, user.email); + const userExists = await checkUserExistence(user.email); - if (signInMethods.length === 0) { + if (!userExists) { await auth.signOut(); - toast.error("You don't have an account yet. Please sign up first."); + toast.info("You don't have an account yet. Please sign up first."); + navigate("/signup"); return; } @@ -91,25 +50,19 @@ const SignIn = () => { let userFound = false; for (const doc of querySnapshot.docs) { - if (doc.data().firebaseUID === user.uid) { + if (doc.data().email === user.email) { userFound = true; const isVerified = doc.data().isVerified; - const onboardingData = doc.data().onboardingData; if (!isVerified) { navigate("/undereview"); return; } - if (isVerified) { - toast.success("Signed in successfully!"); - navigate("/"); - return; - } else { - navigate("/On_boarding_form"); - } - break; + navigate("/"); + toast.success("Signed in successfully!"); + return; } } @@ -130,11 +83,12 @@ const SignIn = () => { const result = await signInWithPopup(auth, googleProvider); const user = result.user; - const signInMethods = await fetchSignInMethodsForEmail(auth, user.email); + const userExists = await checkUserExistence(user.email); - if (signInMethods.length === 0) { + if (!userExists) { await auth.signOut(); - toast.error("You don't have an account yet. Please sign up first."); + toast.info("You don't have an account yet. Please sign up first."); + navigate("/signup"); return; } @@ -144,30 +98,23 @@ const SignIn = () => { let userFound = false; for (const doc of querySnapshot.docs) { - if (doc.data().firebaseUID === user.uid) { + if (doc.data().email === user.email) { userFound = true; const isVerified = doc.data().isVerified; - const onboardingData = doc.data().onboardingData; if (!isVerified) { navigate("/undereview"); return; } - if (isVerified) { - navigate("/"); - return; - } else { - navigate("/On_boarding_form"); - } - break; // Exit the loop once the user document is found + navigate("/"); + toast.success("Signed in successfully!"); + return; } } if (!userFound) { - console.log(userFound); - // User document not found, navigate to onboarding form navigate("/On_boarding_form"); } @@ -186,42 +133,26 @@ const SignIn = () => {