您好,我正在使用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';
})
答案 0 :(得分:0)
您只需要将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