Skip to content

Commit 6b0fdf6

Browse files
committed
Maked use of the logged flag returned by the backend
1 parent d359156 commit 6b0fdf6

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

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

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,12 @@ export class AuthenticationService {
4242
loggedUser = new User();
4343
if (status) {
4444
loggedUser.username = status.username;
45-
loggedUser.logged = true;
45+
loggedUser.logged = status.logged;
4646

47-
const token = window.btoa(username + ':' + password);
48-
loggedUser.token = token;
47+
if (loggedUser.logged) {
48+
const token = window.btoa(username + ':' + password);
49+
loggedUser.token = token;
50+
}
4951
}
5052

5153
this.user = loggedUser;

src/app/login/view/login-view/login-view.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ export class LoginViewComponent implements OnInit {
3737
this.authenticationService.login(login.username, login.password)
3838
.subscribe({
3939
next: user => {
40-
this.failed = false;
40+
console.log(user)
41+
this.failed = !user.logged;
4142
this.loading = false;
4243
if (user.logged) {
4344
this.router.navigate([this.returnUrl]);

0 commit comments

Comments
 (0)