javascript - Firebase 'requires-recent-login' - Stack Overflow

I would like to know about firebase requires-recent-login.If I reauthenticate user like this firebase.

I would like to know about firebase requires-recent-login. If I reauthenticate user like this

firebase.auth().currentUser.reauthenticateAndRetrieveDataWithCredential(
  firebase.auth.EmailAuthProvider.credential(firebase.auth().currentUser.email,
  typedpassword))

to let user change password or email, is there any possibility that requires-recent-login error es out?

I would like to know about firebase requires-recent-login. If I reauthenticate user like this

firebase.auth().currentUser.reauthenticateAndRetrieveDataWithCredential(
  firebase.auth.EmailAuthProvider.credential(firebase.auth().currentUser.email,
  typedpassword))

to let user change password or email, is there any possibility that requires-recent-login error es out?

Share Improve this question edited Jul 10, 2018 at 5:05 Frank van Puffelen 601k85 gold badges890 silver badges860 bronze badges asked Jul 10, 2018 at 2:08 DaibakuDaibaku 12.6k25 gold badges82 silver badges111 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

Some actions require recent authentication and it fails with a auth/requires-recent-login error code.

One action that requires recent authentication is the updating of email.

The solution is to reauthenticate the user, before retrying the action.

import { getAuth, reauthenticateWithCredential } from 'firebase/auth';

const auth = getAuth();
const user = auth.currentUser;

// TODO(you): prompt the user to re-provide their sign-in credentials
const credential = promptForCredentials();

reauthenticateWithCredential(user, credential).then(() => {
  // User re-authenticated.
}).catch((error) => {
  // An error ocurred
  // ...
});

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744895266a4599656.html

相关推荐

  • javascript - Firebase 'requires-recent-login' - Stack Overflow

    I would like to know about firebase requires-recent-login.If I reauthenticate user like this firebase.

    1天前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信