From 18f6e5f01829b400d9ea5a4f0b42b522cf262f89 Mon Sep 17 00:00:00 2001 From: Lukas Kimpel <lukas.kimpel@mni.thm.de> Date: Thu, 8 Mar 2018 22:30:40 +0100 Subject: [PATCH] Refactor username to e-mail Create guestLogin method --- src/app/login/login.component.html | 13 ++++++------- src/app/login/login.component.ts | 4 ++++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/app/login/login.component.html b/src/app/login/login.component.html index 5f51e4107..8cbb790cc 100644 --- a/src/app/login/login.component.html +++ b/src/app/login/login.component.html @@ -1,12 +1,11 @@ -<form (ngSubmit)="login(userName.value, userPassword.value)" fxLayout="column" fxLayoutAlign="space-around" +<form (ngSubmit)="login(userEmail.value, userPassword.value)" fxLayout="column" fxLayoutAlign="space-around" fxLayoutGap="10px"> <mat-form-field class="input-block"> - <input matInput #userName placeholder="Username" [formControl]="usernameFormControl" [errorStateMatcher]="matcher" + <input matInput #userEmail placeholder="E-mail" [formControl]="usernameFormControl" [errorStateMatcher]="matcher" name="username"/> - <mat-error *ngIf="usernameFormControl.hasError('email') && !usernameFormControl.hasError('required')">Username must - be a <strong>valid</strong> email address. + <mat-error *ngIf="usernameFormControl.hasError('email') && !usernameFormControl.hasError('required')">Please enter a <strong>valid</strong> e-mail address. </mat-error> - <mat-error *ngIf="usernameFormControl.hasError('required')">Username is <strong>required</strong>.</mat-error> + <mat-error *ngIf="usernameFormControl.hasError('required')">E-mail is <strong>required</strong>.</mat-error> </mat-form-field> <mat-form-field class="input-block"> @@ -15,8 +14,8 @@ <mat-error *ngIf="passwordFormControl.hasError('required')">Password is <strong>required</strong>.</mat-error> </mat-form-field> - <button mat-raised-button color="primary" (click)="login(userName.value, userPassword.value)">Login</button> - <button mat-raised-button *ngIf="role === UserRole.PARTICIPANT" (click)="login('anonymus', 'nothing')">Login as + <button mat-raised-button color="primary" (click)="login(userEmail.value, userPassword.value)">Login</button> + <button mat-raised-button *ngIf="role === UserRole.PARTICIPANT" (click)="guestLogin()">Login as guest </button> </form> diff --git a/src/app/login/login.component.ts b/src/app/login/login.component.ts index 9af20e5ad..bb630ccc1 100644 --- a/src/app/login/login.component.ts +++ b/src/app/login/login.component.ts @@ -49,6 +49,10 @@ export class LoginComponent implements OnInit { } } + guestLogin(): void { + this.authenticationService.login('guest', 'guest', this.role).subscribe(loginSuccessful => this.checkLogin(loginSuccessful)); + } + private checkLogin(loginSuccessful: boolean) { if (loginSuccessful) { this.notificationService.show('Login successful!'); -- GitLab