Skip to content

Commit a972ec6

Browse files
committed
bring back token management as alternative to cookie token
1 parent 37071be commit a972ec6

File tree

3 files changed

+144
-114
lines changed

3 files changed

+144
-114
lines changed

client/src/app/modules/user/services/user.service.ts

+8-6
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,15 @@ export class UserService extends CrudService<User> {
147147

148148
localStorage.removeItem('waw_user');
149149

150-
this.http.get('/api/user/logout').subscribe(() => {
151-
this._router.navigateByUrl('/sign');
150+
this.http.remove('token');
152151

153-
setTimeout(() => {
154-
location.reload();
155-
}, 100);
156-
});
152+
this.http.get('/api/user/logout');
153+
154+
this._router.navigateByUrl('/sign');
155+
156+
setTimeout(() => {
157+
location.reload();
158+
}, 100);
157159
}
158160

159161
updateAdmin(user: User): void {

client/src/app/pages/guest/sign/sign.component.ts

+6
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,12 @@ export class SignComponent {
179179

180180
private _set = (user: User): void => {
181181
if (user) {
182+
const token = (user as unknown as { token: string }).token || '';
183+
184+
if (token) {
185+
this._http.set('token', token);
186+
}
187+
182188
localStorage.setItem('waw_user', JSON.stringify(user));
183189

184190
this.us.setUser(user);

0 commit comments

Comments
 (0)