Skip to content

Commit 6d292db

Browse files
committed
fixed signup with email/pass account creation issue where it wouldnt create users doc
1 parent a0ecaa5 commit 6d292db

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/contexts/AuthContext.jsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ export const AuthProvider = ({ children }) => {
101101
password
102102
);
103103
const user = userCredentials.user;
104-
const usersRef = collection(db, "users");
105-
await addDoc(usersRef, {
104+
const userRef = doc(db, "users", user.uid);
105+
await setDoc(userRef, {
106106
uid: user.uid,
107107
email: user.email,
108-
usagesLeft: 4,
108+
usagesLeft: 5,
109109
lastReset: serverTimestamp(),
110110
});
111111
} catch (error) {
@@ -142,9 +142,10 @@ export const AuthProvider = ({ children }) => {
142142
const provider = new GoogleAuthProvider();
143143
const userCredentials = await signInWithPopup(auth, provider);
144144
const user = userCredentials.user;
145-
const userDoc = await getDoc(doc(db, "users", user.uid));
145+
const userRef = doc(db, "users", user.uid);
146+
const userDoc = await getDoc(userRef);
146147
if (!userDoc.exists()) {
147-
await setDoc(doc(db, "users", user.uid), {
148+
await setDoc(userRef, {
148149
uid: user.uid,
149150
email: user.email,
150151
usagesLeft: 5,

0 commit comments

Comments
 (0)