context.auth.token.email_verified 在 https 可调用 Firebase 函数中尽管经过验证但仍为假

context.auth.token.email_verified in https callable Firebase function is false despite verification

我试图阻止使用未经验证的电子邮件的用户执行云功能。 我的函数如下所示:

export const myFunction = functions.https.onCall(async (data, context) => {
  if (context.auth && context.auth.token.email_verified) {
    //my actual function code
  } else {
    if (!context.auth) {
      functions.logger.log("unauthenticated call to myFunction");
    } else if (!context.auth.token.email_verified) {
      functions.logger.log("unverified email call to myFunction with token", context.auth.token);
    }
  }
});

我以这种方式从我的本机前端应用程序调用此函数:

const myFunction = firebase.functions().httpsCallable("myFunction");
myFunction(payload);

我通过单击收到的 link 完成了电子邮件验证过程,一切似乎都正常。如果我从前端应用程序登录当前用户,则 emailVerified 属性为 true :

console.log(firebase.auth().currentUser)

但是,调用云函数时,它会记录unverified email call to myFunction with token,并且email_verified prop 是false inside token

我错过了什么吗?两者有何不同?

问题来自令牌刷新,类似于