Richardson
Richardson

Reputation: 2285

How to integrate user type in to firestore authed user?

I am tiring to add user type to a user when creating a user in my app depending on each case ? will this require a cloud function or can I do it right on the fly in frontend when doing the signup ? for example I want a user to be a client... and depending on this I will write my logic.

 const Signin = (email: string, password: string) => {
    signInWithEmailAndPassword(auth, email, password)
      .then((userCredential) => {
        const { user, "USERTYPE" } = userCredential;

        if (!user.emailVerified) {
          _miscContext.SetSnackBarMsg(true, 'Please verify your email');
          return;
        }            
    }

Upvotes: 0

Views: 96

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 598765

If you do this in your client-side code, a user can pick any type they want.

If that is what you want, then it's fine to do this in client-side code.

Otherwise, you'll want to set the user type from a trusted environment, such as your development machine, a server that you control, or Cloud Functions/Cloud Run.

Upvotes: 1

Related Questions