Skip to content

Commit 1dac8e2

Browse files
committed
Takes the token from the login response
1 parent a605b30 commit 1dac8e2

2 files changed

Lines changed: 4 additions & 6 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export class LoginStatus {
22
username: string = '';
33
logged: boolean = false;
4+
token: string = '';
45
}

src/app/authentication/service/authentication.service.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@ export class AuthenticationService {
2121
) { }
2222

2323
public login(username: string, password: string): Observable<User> {
24-
const toUser = (status: LoginStatus) => this.loadUser(username, password, status);
25-
2624
return this.http.post<ApiResponse<LoginStatus>>(this.loginUrl, { username, password })
2725
.pipe(map(response => response.content))
28-
.pipe(map(toUser));
26+
.pipe(map(r => this.loadUser(r)));
2927
}
3028

3129
public logout() {
@@ -36,7 +34,7 @@ export class AuthenticationService {
3634
return this.user;
3735
}
3836

39-
private loadUser(username: string, password: string, status: LoginStatus): User {
37+
private loadUser(status: LoginStatus): User {
4038
let loggedUser;
4139

4240
loggedUser = new User();
@@ -45,8 +43,7 @@ export class AuthenticationService {
4543
loggedUser.logged = status.logged;
4644

4745
if (loggedUser.logged) {
48-
const token = window.btoa(username + ':' + password);
49-
loggedUser.token = token;
46+
loggedUser.token = status.token;
5047
}
5148
}
5249

0 commit comments

Comments
 (0)