bugfix
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
import { STORAGE_KEYS } from './config'
|
||||
import { logger } from './logger'
|
||||
|
||||
// 日志模块名
|
||||
const LOG = 'auth'
|
||||
|
||||
export interface TokenData {
|
||||
accessToken: string
|
||||
@@ -22,12 +26,15 @@ export function setTokens(data: TokenData): void {
|
||||
wx.setStorageSync(STORAGE_KEYS.ACCESS_TOKEN, data.accessToken)
|
||||
wx.setStorageSync(STORAGE_KEYS.REFRESH_TOKEN, data.refreshToken)
|
||||
wx.setStorageSync(STORAGE_KEYS.EXPIRE_TIME, data.expireTime)
|
||||
// 不打印 token 明文,只记录过期时间便于核对单位(秒/毫秒)
|
||||
logger.debug(LOG, 'token 已写入, expireTime=', data.expireTime)
|
||||
}
|
||||
|
||||
export function clearTokens(): void {
|
||||
wx.removeStorageSync(STORAGE_KEYS.ACCESS_TOKEN)
|
||||
wx.removeStorageSync(STORAGE_KEYS.REFRESH_TOKEN)
|
||||
wx.removeStorageSync(STORAGE_KEYS.EXPIRE_TIME)
|
||||
logger.info(LOG, 'token 已清理')
|
||||
}
|
||||
|
||||
export function isLoggedIn(): boolean {
|
||||
|
||||
Reference in New Issue
Block a user