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 3fce9041ec14810bb82fcd9b3e33c020eb502131..d3dbdd74edef50ad8d264b4936636644864bfb88 100644 --- a/src/app/services/http/authentication.service.ts +++ b/src/app/services/http/authentication.service.ts @@ -40,13 +40,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> { @@ -98,14 +98,16 @@ export class AuthenticationService { return this.user.token; } - 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;