在 firebase 9 模块中应用 applyActionCode 时验证电子邮件时获取用户 ID?

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

如何访问电子邮件验证用户的 uid?在这种情况下,res 会发送任何有用的想法吗?我应该从其他地方处理吗?

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');
      });
  };

applyActionCode函数returns一个Promise<void>,所以你的res不会有值。但是,由于操作代码应用于当前用户,您可以通过以下方式确定他们的 UID:

auth.currentUser.uid