Повторная проверка подлинности Angular Fire при сбое обновления электронной почты - PullRequest
0 голосов
/ 12 октября 2019

Я настроил свою повторную аутентификацию для пользователя, чтобы он обновлял свою электронную почту и пароль, но сталкивается с ошибкой, когда повторная аутентификация для электронной почты завершается неудачно, когда она прошла повторную аутентификацию для моего пароля и успешно обновляет ее.

changePassword = (currentPassword, newPassword) => {
  this.authService.reauthenticate(currentPassword).then(() => {
    var user = this.afAuth.auth.currentUser;
    user.updatePassword(newPassword).then(() => {
      console.log("Password updated!");
    }).catch((error) => { console.log(error); });
  }).catch((error) => { console.log(error); });
  this.toggle();
}
changeEmail = (currentPassword, newEmail) => {
  this.authService.reauthenticate(currentPassword).then(() => {
    var user = this.afAuth.auth.currentUser;
    user.updateEmail(newEmail).then(() => {
    }).catch((error) => { console.log(error); });
  }).catch((error) => { console.log(error); });
  this.toggle();
}

и в случае, если кто-то должен увидеть мой HTML

  <!-- Update user credentials with reauthentication -->
  <div class="card-header mt-3">
    <div class=" pt-3 pb-2 mb-3">
      <h2 class="h2"> Update Email</h2>
    </div>
    <form (ngSubmit)="this.userService.changeEmail(password.value, newEmail.value)">
      <mat-form-field>
        <input matInput type="password" placeholder="Password" #password required>
      </mat-form-field>
      <mat-form-field>
        <input matInput type="text" placeholder="New Email" #newEmail required>
      </mat-form-field>
      <button mat-raised-button type="submit" class="mb-3">Update Email</button>
    </form>
  </div>

<div class="card-header mt-3">
    <div class=" pt-3 pb-2 mb-3">
      <h2 class="h2"> Update Password</h2>
    </div>
<form (ngSubmit)="this.userService.changePassword(password.value, newPassword.value)">
    <mat-form-field>
      <input matInput type="password" placeholder="Current Password" #password required>
    </mat-form-field>
    <mat-form-field>
      <input matInput type="password" placeholder="New Password" #newPassword required>
    </mat-form-field>
    <button mat-raised-button type="submit" class="mb-3">Update Password</button>
  </form>

, и это сообщение, которое я получаю

M {code: "auth / неправильный пароль", сообщение: "Theневерный пароль или у пользователя нет пароля. "}

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...