feat: refresh-token (#9286)

Co-authored-by: NFish <douxc512@gmail.com>
This commit is contained in:
Wu Tianwei
2024-10-12 23:40:38 +08:00
committed by GitHub
parent 70c5b23089
commit dbfbc56de7
8 changed files with 164 additions and 12 deletions

View File

@@ -11,6 +11,7 @@ import { IS_CE_EDITION, SUPPORT_MAIL_LOGIN, apiPrefix, emailRegex } from '@/conf
import Button from '@/app/components/base/button'
import { login, oauth } from '@/service/common'
import { getPurifyHref } from '@/utils'
import useRefreshToken from '@/hooks/use-refresh-token'
type IState = {
formValid: boolean
@@ -61,6 +62,7 @@ function reducer(state: IState, action: IAction) {
const NormalForm = () => {
const { t } = useTranslation()
const { getNewAccessToken } = useRefreshToken()
const useEmailLogin = IS_CE_EDITION || SUPPORT_MAIL_LOGIN
const router = useRouter()
@@ -95,7 +97,9 @@ const NormalForm = () => {
},
})
if (res.result === 'success') {
localStorage.setItem('console_token', res.data)
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')
}
else {