You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is quite a bit of work for a minor optimisation, so don't take this as something you have to implement!
Assuming here that a tutor document is the same as the person/email that logs in.
Not sure how tutor documents are being created at the moment.
But if login accounts and tutors are the same email, then when you sign up(create a new user) you might want to create a tutor document with the same uid as the login uid.
consttutorData={// whatever other properties a tutor document needs}
auth.createUserWithEmailAndPassword(email,password).then((credentials)=>{db.collection("Users").add(credentials.user.uid).set({email,...tutorData)
this then means that the uid of a tutor document will be equal to auth.currentUser.uid, so instead of
having auth uid as the id for tutor documents will also help in other places, if you have content that is private to a user, you can set the auth uid as a "owner" or "createdBy" key on a document (say a lesson) and then you can write a firebase rule to only allow reading when the logged in user is the same as the user who created the document
allow read,write: if request.auth.uid == resource.createdBy
The text was updated successfully, but these errors were encountered:
btw the .then() chaining is kind of inevitable as this is a promise based workflow, things do not return values immediately.
you can use async-await if you want but it's probably better to keep things as they are so your database read/writes aren't blocking an other code from running.
you can always set state inside a .then() chained on a db call, and then use that state elsewhere in the react component
This is quite a bit of work for a minor optimisation, so don't take this as something you have to implement!
Assuming here that a tutor document is the same as the person/email that logs in.
Not sure how tutor documents are being created at the moment.
But if login accounts and tutors are the same email, then when you sign up(create a new user) you might want to create a tutor document with the same uid as the login uid.
this then means that the uid of a tutor document will be equal to auth.currentUser.uid, so instead of
you can do
having auth uid as the id for tutor documents will also help in other places, if you have content that is private to a user, you can set the auth uid as a "owner" or "createdBy" key on a document (say a lesson) and then you can write a firebase rule to only allow reading when the logged in user is the same as the user who created the document
allow read,write: if request.auth.uid == resource.createdBy
The text was updated successfully, but these errors were encountered: