在https可调用的Firebase函数中验证的context.auth.token.email_verified是fa



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

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

我用这种方式从我的react原生前端应用程序调用这个函数:

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

我通过点击收到的链接完成了电子邮件验证过程,一切似乎都很好。如果我从前端应用程序记录我的当前用户,则emailVerified道具为true:

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

然而,当调用云函数时,它会记录unverified email call to myFunction with token,并且email_verified道具是令牌中的false

我是不是错过了什么?两者怎么会不同呢?

问题来自令牌刷新,类似于https://stackoverflow.com/a/47281903/6353365

最新更新