diff --git a/src/app/models/user.ts b/src/app/models/user.ts index e37a93bde4dc3b5714ca8169ae115db99aa59fcf..369934fdf1171884a0ca9bdeb4bfc195fe52914a 100644 --- a/src/app/models/user.ts +++ b/src/app/models/user.ts @@ -7,12 +7,14 @@ export class User { authProvider: AuthProvider; token: string; role: UserRole; + isGuest: boolean; - constructor(id: string, loginId: string, authProvider: AuthProvider, token: string, role: UserRole) { + constructor(id: string, loginId: string, authProvider: AuthProvider, token: string, role: UserRole, isGuest: boolean) { this.id = id; this.loginId = loginId; this.authProvider = authProvider; this.token = token; this.role = role; + this.isGuest = isGuest; } } diff --git a/src/app/services/http/authentication.service.ts b/src/app/services/http/authentication.service.ts index d0ed68091baf40ef7b3a196a0ba1fd970bccd710..6de00a2b44b7b3fbb1a4105880616ad94df02a41 100644 --- a/src/app/services/http/authentication.service.ts +++ b/src/app/services/http/authentication.service.ts @@ -41,13 +41,13 @@ export class AuthenticationService { return this.checkLogin(this.http.post<ClientAuthentication>(connectionUrl, { loginId: email, password: password - }, this.httpOptions), userRole); + }, this.httpOptions), userRole, false); } guestLogin(): Observable<boolean> { const connectionUrl: string = this.apiUrl.base + this.apiUrl.auth + this.apiUrl.login + this.apiUrl.guest; - return this.checkLogin(this.http.post<ClientAuthentication>(connectionUrl, null, this.httpOptions), UserRole.PARTICIPANT); + return this.checkLogin(this.http.post<ClientAuthentication>(connectionUrl, null, this.httpOptions), UserRole.PARTICIPANT, true); } register(email: string, password: string): Observable<boolean> { @@ -99,14 +99,16 @@ export class AuthenticationService { return this.isLoggedIn() ? this.user.getValue().token : undefined; } - private checkLogin(clientAuthentication: Observable<ClientAuthentication>, userRole: UserRole): Observable<boolean> { + private checkLogin(clientAuthentication: Observable<ClientAuthentication>, userRole: UserRole, isGuest: boolean): Observable<boolean> { return clientAuthentication.map(result => { if (result) { this.setUser(new User( result.userId, result.loginId, result.authProvider, - result.token, userRole)); + result.token, + userRole, + isGuest)); return true; } else { return false;