Angular/Firebase 更改密码后重定向到登录页面?

Angular/Firebase redirect to Login page after password change?

您好,我正在使用 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); 
  }

忘记密码-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"}); 
  }

也不要 return 承诺并同时尝试捕获它,您应该允许任何调用 resetPassword() 来处理错误。

文档: https://firebase.google.com/docs/auth/web/passing-state-in-email-actions#passing_statecontinue_url_in_email_actions

或者,您可以创建自己的着陆页,以便拥有更多控制权: https://firebase.google.com/docs/auth/custom-email-handler