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