Firebase Auth-更新用户的电子邮件后,Firebase Auth注销用户 [英] Firebase Auth - After updating the user's email, Firebase Auth logs out the user

查看:102
本文介绍了Firebase Auth-更新用户的电子邮件后,Firebase Auth注销用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用中使用Firebase Auth.我更新电子邮件如下:

I am using Firebase Auth in my app. I update the email like follows:

firebaseAuth.currentUser?.updateEmail(email)

电子邮件正在更新100%(必要时我也会重新验证).我的问题是电子邮件更改后,用户已从其帐户中注销,必须再次登录.

The email is updating 100% (I do a re-auth when necessary as well). My problem is after the e-mail has changed, the user is being logged out of his account and has to login again.

当我打电话

val user = firebaseAuth.currentUser 

更新电子邮件后,用户为空,我的应用希望您使用新的电子邮件地址再次登录.

after updating the email the user is null and my app wants you to login again with the new email address.

这是正确的行为吗?更改帐户电子邮件后,必须重新登录会给用户带来非常糟糕的体验.

Is this the correct behaviour? It makes for a really bad user experience having to login again after changing the account email.

推荐答案

出于安全原因,我认为Firebase故意这样做.您可以通过更改用户电子邮件后自动调用Firebase的登录功能来解决此问题.

I think Firebase is doing this on purpose for security reasons. You could work around this by calling the Firebase's login function automatically after changing the user's email.

但是,如果您使用的是最新版本的Firebase,我认为这不是正常现象.他们在其文档中明确指出您需要重新认证用户才能执行任何配置文件更改(如果他最近未登录).

However, I don't think that it is a normal behaviour if you're using the most recent version of Firebase. They explicitly state in their documentation that you need to re-authenticate the user to perform any profile change (if he hasn't signed in recently).

某些对安全性敏感的操作(例如删除帐户,设置主电子邮件地址和更改密码)要求用户最近登录.如果执行这些操作之一,并且用户登录时间过长以前,该操作失败,并显示FIRAuthErrorCodeCredentialTooOld错误.

Some security-sensitive actions—such as deleting an account, setting a primary email address, and changing a password—require that the user has recently signed in. If you perform one of these actions, and the user signed in too long ago, the action fails with the FIRAuthErrorCodeCredentialTooOld error.

在我这方面,此效果仅在用户登录的其他设备上发生,而不在执行编辑操作的设备上发生.

On my side, this effect only occurs on other devices on which the user has signed in, not on the device on which the edit action was performed.

这篇关于Firebase Auth-更新用户的电子邮件后,Firebase Auth注销用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆