Skip to content

Commit 5f64b39

Browse files
authored
Update user.service.ts
Loses authorization when pages are refreshed
1 parent 6477bc3 commit 5f64b39

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/app/core/services/user.service.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ export class UserService {
2626
// This runs once on application startup.
2727
populate() {
2828
// If JWT detected, attempt to get & store user's info
29-
if (this.jwtService.getToken()) {
30-
this.apiService.get('/user')
31-
.subscribe(
32-
data => this.setAuth(data.user),
33-
err => this.purgeAuth()
29+
const token = this.jwtService.getToken();
30+
if (token) {
31+
this.apiService.get("/user").subscribe(
32+
(data) => {
33+
return this.setAuth({ ...data.user, token });
34+
},
35+
(err) => this.purgeAuth()
3436
);
3537
} else {
3638
// Remove any potential remnants of previous auth states

0 commit comments

Comments
 (0)