File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ,
You can’t perform that action at this time.
0 commit comments