Skip to content

Commit

Permalink
fix: signOut 没有刷新 lastRefreshedAt
Browse files Browse the repository at this point in the history
  • Loading branch information
gxmari007 committed Jan 9, 2024
1 parent 8726b63 commit 805a593
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/runtime/composables/local/use-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,12 @@ const signUp: SignUp<Credentials, any> = async (credentials, signUpOptions = {},
*/
const signOut: SignOut<any> = async (signOutOptions = {}, fetchOptions) => {
const config = useTypedConfig(useRuntimeConfig(), 'local')
const { data, token, clearToken } = useAuthState()
const { data, token, lastRefreshedAt, clearToken } = useAuthState()
const headers = new Headers(token.value ? { [config.token.headerName]: token.value } : undefined)

// 清理登录用户信息
data.value = null
lastRefreshedAt.value = null
clearToken()

const signOutConfig = config.endpoints.signOut
Expand Down
3 changes: 2 additions & 1 deletion src/runtime/composables/refresh/use-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const signOut: ReturnType<typeof useLocalAuth>['signOut'] = async (
// 1. 获取 signOut endpoint 配置
const config = useTypedConfig(useRuntimeConfig(), 'refresh')
const signOutConfig = config.endpoints.signOut
const { token, data, clearToken, clearRefreshToken } = useAuthState()
const { token, data, lastRefreshedAt, clearToken, clearRefreshToken } = useAuthState()
let response

// 2. 发起 signOut 请求
Expand All @@ -96,6 +96,7 @@ const signOut: ReturnType<typeof useLocalAuth>['signOut'] = async (

// 3. 清理 token, refreshToken, session
data.value = null
lastRefreshedAt.value = null
clearToken()
clearRefreshToken()

Expand Down

0 comments on commit 805a593

Please sign in to comment.