Added bad login error feedback (Fixes #17)
This commit is contained in:
		@@ -1,5 +1,6 @@
 | 
			
		||||
<mat-dialog-content>
 | 
			
		||||
    <h3 mat-dialog-title>Login</h3>
 | 
			
		||||
    <div *ngIf="error" class="alert alert-danger">Invalid email or password</div>
 | 
			
		||||
    <form id="loginForm">
 | 
			
		||||
        <mat-form-field class="w-100">
 | 
			
		||||
            <input matInput placeholder="Email" name="email" [(ngModel)]="email">
 | 
			
		||||
 
 | 
			
		||||
@@ -8,13 +8,22 @@ import {MatDialogRef} from '@angular/material';
 | 
			
		||||
})
 | 
			
		||||
export class LoginComponent {
 | 
			
		||||
  email: string;
 | 
			
		||||
  error = false;
 | 
			
		||||
  password: string;
 | 
			
		||||
 | 
			
		||||
  constructor(private dialogRef: MatDialogRef<LoginComponent>, private afAuth: AngularFireAuth) {}
 | 
			
		||||
 | 
			
		||||
  login() {
 | 
			
		||||
    this.afAuth.auth.signInWithEmailAndPassword(this.email, this.password).then(user => {
 | 
			
		||||
      if (user) this.dialogRef.close();
 | 
			
		||||
    });
 | 
			
		||||
    this.error = false;
 | 
			
		||||
    this.afAuth.auth
 | 
			
		||||
      .signInWithEmailAndPassword(this.email, this.password)
 | 
			
		||||
      .then(user => {
 | 
			
		||||
        if (user) {
 | 
			
		||||
          this.dialogRef.close();
 | 
			
		||||
        } else {
 | 
			
		||||
          this.error = true;
 | 
			
		||||
        }
 | 
			
		||||
      })
 | 
			
		||||
      .catch(err => (this.error = true));
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user