|
|
|
@ -485,19 +485,7 @@ export class AuthService { |
|
|
|
} else { |
|
|
|
this.updateAndValidateTokens(loginResponse.token, loginResponse.refreshToken, true); |
|
|
|
} |
|
|
|
const authUser = getCurrentAuthUser(this.store); |
|
|
|
const tokenData = this.jwtHelper.decodeToken(loginResponse.token); |
|
|
|
if (['sub', 'firstName', 'lastName'].some(value => authUser[value] !== tokenData[value])) { |
|
|
|
this.store.dispatch(new ActionAuthUpdateAuthUser({ |
|
|
|
authUser: { |
|
|
|
...authUser, ...{ |
|
|
|
sub: tokenData.sub, |
|
|
|
firstName: tokenData.firstName, |
|
|
|
lastName: tokenData.lastName, |
|
|
|
} |
|
|
|
} |
|
|
|
})); |
|
|
|
} |
|
|
|
this.updatedAuthUserFromToken(loginResponse.token); |
|
|
|
this.refreshTokenSubject.next(loginResponse); |
|
|
|
this.refreshTokenSubject.complete(); |
|
|
|
this.refreshTokenSubject = null; |
|
|
|
@ -511,6 +499,18 @@ export class AuthService { |
|
|
|
return response; |
|
|
|
} |
|
|
|
|
|
|
|
private updatedAuthUserFromToken(token: string) { |
|
|
|
const authUser = getCurrentAuthUser(this.store); |
|
|
|
const tokenData = this.jwtHelper.decodeToken(token); |
|
|
|
if (['sub', 'firstName', 'lastName'].some(value => authUser[value] !== tokenData[value])) { |
|
|
|
this.store.dispatch(new ActionAuthUpdateAuthUser({ |
|
|
|
sub: tokenData.sub, |
|
|
|
firstName: tokenData.firstName, |
|
|
|
lastName: tokenData.lastName, |
|
|
|
})); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private validateJwtToken(doRefresh): Observable<void> { |
|
|
|
const subject = new ReplaySubject<void>(); |
|
|
|
if (!AuthService.isTokenValid('jwt_token')) { |
|
|
|
|