From afd370d6fbf5cbd4a1302449fb4796c7e42cd9ad Mon Sep 17 00:00:00 2001 From: Lukas Kimpel <lukas.kimpel@mni.thm.de> Date: Tue, 13 Mar 2018 12:53:58 +0100 Subject: [PATCH] Refactor login component to use new features --- src/app/login/login.component.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/app/login/login.component.ts b/src/app/login/login.component.ts index cc6bcb187..f4156f3e1 100644 --- a/src/app/login/login.component.ts +++ b/src/app/login/login.component.ts @@ -45,7 +45,7 @@ export class LoginComponent implements OnInit { if (!this.usernameFormControl.hasError('required') && !this.usernameFormControl.hasError('email') && !this.passwordFormControl.hasError('required')) { - this.authenticationService.login(username, password, this.role).subscribe(loginSuccessful => this.checkLogin(loginSuccessful)); + this.authenticationService.login(username, password).subscribe(loginSuccessful => this.checkLogin(loginSuccessful)); } else { this.notificationService.show('Please fit the requirements shown above.'); } @@ -55,8 +55,15 @@ export class LoginComponent implements OnInit { this.authenticationService.guestLogin().subscribe(loginSuccessful => this.checkLogin(loginSuccessful)); } - private checkLogin(loginSuccessful: boolean) { + private checkLogin(loginSuccessful: ClientAuthentication) { if (loginSuccessful) { + const user: User = new User( + loginSuccessful.userId, + loginSuccessful.loginId, + loginSuccessful.authProvider, + loginSuccessful.token, + this.role); + this.authenticationService.setUser(user); this.notificationService.show('Login successful!'); if (this.role === UserRole.CREATOR) { this.router.navigate(['creator']); -- GitLab