如何解决更改密码后,Angular / Firebase重定向到“登录”页面吗?
您好,我正在使用Angular和Firebase进行身份验证。我有一个简短的问题
在成功重置密码后,有人知道如何使提示重定向到登录页面吗?
- 我有一个忘记密码的页面,然后询问电子邮件
- 然后将链接发送到电子邮件,电子邮件将要求用户输入新密码
上面提到的两个已成功配置,但是在成功更改密码后,我很难解决如何实现重定向到登录页面
The page only stays here after the password change
Authservice.ts密码重置方法
resetPassword(email: string) {
return this.afAuth.sendPasswordResetEmail(email)
.catch(error => throw error);
}
Forgotpassword-component.ts
async resetPassword() {
this.clearMessages();
this.isClicked = true;
this.actionButtonLabel = "Please wait...";
await this.authService.resetPassword(this.userName).then(() => {
this.actionButtonLabel = "Reset Password";
this.alert.code = '200';
this.alert.message = "A password reset link has been sent to your email address.";
this.alert.status = 'success';
}).catch(err => {
this.isClicked = false;
this.actionButtonLabel = "Reset Password";
this.alert.code = err.code;
this.alert.message = FirebaseErrors.Parse(err.code);
this.alert.status = 'failed';
})
解决方法
您只需要将URL传递给sendPasswordResetEmail()函数,如下所示:
resetPassword(email: string) {
return this.afAuth.sendPasswordResetEmail(email,{url: "http://example.com/login"});
}
也不要返回承诺并尝试同时捕获它,您应该允许任何调用resetPassword()处理错误的人。
或者,您可以创建自己的着陆页,以便拥有更多控制权: https://firebase.google.com/docs/auth/custom-email-handler
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。