Added bad login error feedback (Fixes #17)

This commit is contained in:
Zakary Timson 2018-07-24 22:49:41 -04:00
parent 5802840da5
commit d7241c26ad
2 changed files with 13 additions and 3 deletions

View File

@ -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">

View File

@ -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));
}
}