Home > database >  get user id when verify an email when applying an applyActionCode in firebase 9 modular?
get user id when verify an email when applying an applyActionCode in firebase 9 modular?

Time:03-19

How to access the uid of a email verified user ? will the res send any useful idea in this case of should I handle this from somewhere else ?

const handleVerifyEmail = (auth: any, actionCode: any) => {
    applyActionCode(auth, actionCode!)
      .then((res) => {
        //SUCCESS: EMAIL VERIFIED
        console.log(res, 'user UID ?');
        // updateDoc(doc(db, 'Data', res.user.uid), {
        //   verifiedEmail: true,
        // });
      })
      .catch((error) => {
        errorHandeling(error, 'Cannot verify email');
      });
  };

CodePudding user response:

The applyActionCode function returns a Promise<void>, so your res won't have a value. Since the action code is applied to the current user however, you can determine their UID with:

auth.currentUser.uid
  • Related