Skip to content
Snippets Groups Projects
Commit 460026ba authored by FORESTIER Fabien's avatar FORESTIER Fabien
Browse files

Prevent user to think they are authenticated while their token is expired

parent 7ea95eac
No related branches found
No related tags found
1 merge request!49Version 2.3.1
Pipeline #1751 passed
...@@ -46,16 +46,17 @@ export function initAppConfig(appConfigService: AppConfigService) { ...@@ -46,16 +46,17 @@ export function initAppConfig(appConfigService: AppConfigService) {
Angulartics2Module.forRoot(), Angulartics2Module.forRoot(),
], ],
providers: [ providers: [
// The order is important as the InitUserService require the configuration of the app
{ {
provide: APP_INITIALIZER, provide: APP_INITIALIZER,
useFactory: initUserService, useFactory: initAppConfig,
deps: [UserService], deps: [AppConfigService],
multi: true, multi: true,
}, },
{ {
provide: APP_INITIALIZER, provide: APP_INITIALIZER,
useFactory: initAppConfig, useFactory: initUserService,
deps: [AppConfigService], deps: [UserService],
multi: true, multi: true,
}, },
], ],
......
...@@ -42,7 +42,11 @@ export class UserService { ...@@ -42,7 +42,11 @@ export class UserService {
setUserInfo() { setUserInfo() {
const userInfo = JSON.parse(localStorage.getItem('userInfo')); const userInfo = JSON.parse(localStorage.getItem('userInfo'));
if (userInfo) { if (userInfo) {
this._user = new User(userInfo); if (userInfo.exp > Date.now()) {
this._user = new User(userInfo);
} else {
this.resetAuth();
}
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment