fix: save access_token and refresh_token to the localStorage after login success

This commit is contained in:
NFish 2024-10-12 14:08:51 +08:00
parent 8c1fcc91d3
commit c12cb2913a
3 changed files with 8 additions and 1 deletions

View File

@ -29,8 +29,11 @@ const SwrInitor = ({
if (consoleTokenFromLocalStorage && refreshTokenFromLocalStorage)
getNewAccessToken(consoleTokenFromLocalStorage, refreshTokenFromLocalStorage)
if (consoleToken && refreshToken)
if (consoleToken && refreshToken) {
localStorage.setItem('console_token', consoleToken)
localStorage.setItem('refresh_token', refreshToken)
getNewAccessToken(consoleToken, refreshToken)
}
router.replace('/apps', { forceOptimisticNavigation: false } as any)
setInit(true)

View File

@ -97,6 +97,8 @@ const NormalForm = () => {
},
})
if (res.result === 'success') {
localStorage.setItem('console_token', res.data.access_token)
localStorage.setItem('refresh_token', res.data.refresh_token)
getNewAccessToken(res.data.access_token, res.data.refresh_token)
router.replace('/apps')
}

View File

@ -29,6 +29,8 @@ const UserSSOForm: FC<UserSSOFormProps> = ({
useEffect(() => {
if (refreshToken && consoleToken) {
localStorage.setItem('console_token', consoleToken)
localStorage.setItem('refresh_token', refreshToken)
getNewAccessToken(consoleToken, refreshToken)
router.replace('/apps')
}