mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-21 22:40:34 -04:00
Adding errors to the login/register view
This commit is contained in:
parent
44605c4360
commit
ccbda0fd74
@ -29,6 +29,11 @@
|
||||
</mat-form-field>
|
||||
<br/>
|
||||
<mat-checkbox class="pl-3" [(ngModel)]="loginInformation.stayLoggedIn" name="rememberme">Stay logged in</mat-checkbox>
|
||||
<br/>
|
||||
<br/>
|
||||
<mat-error *ngFor="let item of this.loginErrors;">
|
||||
{{item.description}}
|
||||
</mat-error>
|
||||
</mat-card-content>
|
||||
<div fxFlexAlign="end" align="end" style="text-align: end">
|
||||
<button mat-button type="submit" [disabled]="!loginForm.valid">Login</button>
|
||||
@ -73,6 +78,10 @@
|
||||
Error: {{signinPassword.getError("passwordError")["error"]}}
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-error *ngFor="let item of this.registerErrors;">
|
||||
{{item.description}}
|
||||
</mat-error>
|
||||
</mat-card-content>
|
||||
<div fxFlexAlign="end" align="end" style="text-align: end">
|
||||
<button mat-button type="submit" [disabled]="!signinForm.valid">Sigin</button>
|
||||
|
@ -17,6 +17,9 @@ export class LoginComponent
|
||||
hidePassword: boolean = true;
|
||||
redirectURI: string;
|
||||
|
||||
loginErrors: [{code: string, description: string}];
|
||||
registerErrors: [{code: string, description: string}];
|
||||
|
||||
constructor(private router: Router, private route: ActivatedRoute, private http: HttpClient, private snackBar: MatSnackBar)
|
||||
{
|
||||
if (this.route.snapshot.queryParams["ReturnUrl"])
|
||||
@ -29,14 +32,11 @@ export class LoginComponent
|
||||
{
|
||||
this.http.post("/api/account/login", this.loginInformation).pipe(catchError((error =>
|
||||
{
|
||||
console.log(error.status + " - " + error.message);
|
||||
this.snackBar.open(`An unknown error occured: ${error.message}.`, null, { horizontalPosition: "left", panelClass: ['snackError'], duration: 2500 });
|
||||
this.loginErrors = error.error;
|
||||
return EMPTY;
|
||||
}))).subscribe(() =>
|
||||
{
|
||||
window.location.href = this.redirectURI;
|
||||
}, error => {
|
||||
console.log("Login error: " + error);
|
||||
});
|
||||
}
|
||||
|
||||
@ -50,8 +50,7 @@ export class LoginComponent
|
||||
// @ts-ignore
|
||||
this.http.post<string>("/api/account/register", this.signinInformation, {responseType: "text"}).pipe(catchError((error =>
|
||||
{
|
||||
console.log(error.status + " - " + error.message);
|
||||
this.snackBar.open(`An unknown error occured: ${error.message}.`, null, { horizontalPosition: "left", panelClass: ['snackError'], duration: 2500 });
|
||||
this.registerErrors = JSON.parse(error.error);
|
||||
return EMPTY;
|
||||
}))).subscribe(otac => { this.useOTAC(otac); });
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user