diff options
author | crupest <crupest@outlook.com> | 2019-03-06 17:47:25 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2019-03-06 17:47:25 +0800 |
commit | 2a408188bea1adfe66e16a9859e75ace473b6aec (patch) | |
tree | 4194ec6b0241828c9adc7c9f4813dfe986beaeb1 /Timeline/ClientApp/src | |
parent | b88024ad8ad1d5c0b2cace6cd1a987b3a7e70fe4 (diff) | |
download | timeline-2a408188bea1adfe66e16a9859e75ace473b6aec.tar.gz timeline-2a408188bea1adfe66e16a9859e75ace473b6aec.tar.bz2 timeline-2a408188bea1adfe66e16a9859e75ace473b6aec.zip |
...
Diffstat (limited to 'Timeline/ClientApp/src')
4 files changed, 8 insertions, 15 deletions
diff --git a/Timeline/ClientApp/src/app/user-dialog/user-dialog.component.css b/Timeline/ClientApp/src/app/user-dialog/user-dialog.component.css index 868749cf..a443e3c0 100644 --- a/Timeline/ClientApp/src/app/user-dialog/user-dialog.component.css +++ b/Timeline/ClientApp/src/app/user-dialog/user-dialog.component.css @@ -1,6 +1,5 @@ -.progress-container { +.container { display: flex; justify-content: center; align-content: center; } - diff --git a/Timeline/ClientApp/src/app/user-dialog/user-dialog.component.html b/Timeline/ClientApp/src/app/user-dialog/user-dialog.component.html index e790aec1..1e1f1b79 100644 --- a/Timeline/ClientApp/src/app/user-dialog/user-dialog.component.html +++ b/Timeline/ClientApp/src/app/user-dialog/user-dialog.component.html @@ -1,7 +1,5 @@ -<div [ngSwitch]="state"> - <div *ngSwitchCase="'loading'" class="progress-container"> - <mat-progress-spinner mode="indeterminate" diameter="50"></mat-progress-spinner> - </div> +<div [ngSwitch]="state" class="container"> + <mat-progress-spinner *ngSwitchCase="'loading'" mode="indeterminate" diameter="50"></mat-progress-spinner> <app-user-login *ngSwitchCase="'login'" (login)="login($event)" [message]="loginMessage"></app-user-login> <div *ngSwitchCase="'success'"> <p class="mat-body">You have been login as {{ userInfo.username }}.</p> diff --git a/Timeline/ClientApp/src/app/user-dialog/user-dialog.component.ts b/Timeline/ClientApp/src/app/user-dialog/user-dialog.component.ts index 368a1775..88e48799 100644 --- a/Timeline/ClientApp/src/app/user-dialog/user-dialog.component.ts +++ b/Timeline/ClientApp/src/app/user-dialog/user-dialog.component.ts @@ -23,11 +23,7 @@ export class UserDialogComponent implements OnInit { this.userInfo = result.userInfo; this.state = 'success'; } else { - if (result.state === 'invalid') { - this.loginMessage = 'invalidlogin'; - } else if (result.state === 'nologin') { - this.loginMessage = 'nologin'; - } + this.loginMessage = result.state; this.state = 'login'; } }); diff --git a/Timeline/ClientApp/src/app/user-dialog/user.service.ts b/Timeline/ClientApp/src/app/user-dialog/user.service.ts index b0a6eb15..47e98d4d 100644 --- a/Timeline/ClientApp/src/app/user-dialog/user.service.ts +++ b/Timeline/ClientApp/src/app/user-dialog/user.service.ts @@ -28,7 +28,7 @@ export interface TokenValidationResult { } export interface UserLoginState { - state: 'nologin' | 'invalid' | 'success'; + state: 'nologin' | 'invalidlogin' | 'success'; userInfo?: UserInfo; } @@ -45,7 +45,7 @@ export class AlreadyLoginException extends Error { } export class BadCredentialsException extends Error { - constructor(username: string = null , password: string = null) { + constructor() { super(`Username or password is wrong.`); } } @@ -82,7 +82,7 @@ export class UserService { this.token = null; this.userInfo = null; return <UserLoginState>{ - state: 'invalid' + state: 'invalidlogin' }; } }) @@ -103,7 +103,7 @@ export class UserService { return throwError(new BadNetworkException()); } else if (error.status === 400) { console.error('An error occurred when login: wrong credentials.'); - return throwError(new BadCredentialsException(username, password)); + return throwError(new BadCredentialsException()); } else { console.error('An unknown error occurred when login: ' + error); return throwError(error); |