Skip to content
Snippets Groups Projects
Verified Commit 18f6e5f0 authored by Lukas Maximilian Kimpel's avatar Lukas Maximilian Kimpel
Browse files

Refactor username to e-mail

Create guestLogin method
parent 41dae821
No related merge requests found
<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"> fxLayoutGap="10px">
<mat-form-field class="input-block"> <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"/> name="username"/>
<mat-error *ngIf="usernameFormControl.hasError('email') && !usernameFormControl.hasError('required')">Username must <mat-error *ngIf="usernameFormControl.hasError('email') && !usernameFormControl.hasError('required')">Please enter a <strong>valid</strong> e-mail address.
be a <strong>valid</strong> email address.
</mat-error> </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>
<mat-form-field class="input-block"> <mat-form-field class="input-block">
...@@ -15,8 +14,8 @@ ...@@ -15,8 +14,8 @@
<mat-error *ngIf="passwordFormControl.hasError('required')">Password is <strong>required</strong>.</mat-error> <mat-error *ngIf="passwordFormControl.hasError('required')">Password is <strong>required</strong>.</mat-error>
</mat-form-field> </mat-form-field>
<button mat-raised-button color="primary" (click)="login(userName.value, userPassword.value)">Login</button> <button mat-raised-button color="primary" (click)="login(userEmail.value, userPassword.value)">Login</button>
<button mat-raised-button *ngIf="role === UserRole.PARTICIPANT" (click)="login('anonymus', 'nothing')">Login as <button mat-raised-button *ngIf="role === UserRole.PARTICIPANT" (click)="guestLogin()">Login as
guest guest
</button> </button>
</form> </form>
...@@ -49,6 +49,10 @@ export class LoginComponent implements OnInit { ...@@ -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) { private checkLogin(loginSuccessful: boolean) {
if (loginSuccessful) { if (loginSuccessful) {
this.notificationService.show('Login successful!'); this.notificationService.show('Login successful!');
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment