Skip to content

Commit

Permalink
fix: refreshToken when idToken empty -> false
Browse files Browse the repository at this point in the history
  • Loading branch information
chenweigh committed Sep 29, 2024
1 parent d4cc325 commit 7986b15
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions xterio-auth/src/modules/XterAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,18 @@ export class XterioAuth {
if (_tokens) {
XterioAuthTokensManager.setTokens(_tokens)
}
const id_token = XterioAuthTokensManager.idToken
const refresh_token = XterioAuthTokensManager.refreshToken
if (!id_token && refresh_token) {
if (!XterioAuth.isVaildIdToken && refresh_token) {
//req tokens by refresh
XLog.info('refresh tokens')
const res = await XterioAuthService.refreshTokenService(refresh_token)
XterioAuthTokensManager.setTokens({ refresh_token, id_token: res.id_token, access_token: res.access_token })
}

const isvalid = XterioAuth.isVaildIdToken
XLog.info('check the tokens valid status:', isvalid)
if (!isvalid) {
XLog.info('clear cache data')
this.clearData()
} else if (_flag === 'init') {
//get userinfo
Expand Down

0 comments on commit 7986b15

Please sign in to comment.