瀏覽代碼

feat: auto-login after admin account setup (#24395)

tags/1.8.0
-LAN- 2 月之前
父節點
當前提交
f7416eb810
No account linked to committer's email address
共有 1 個文件被更改,包括 22 次插入2 次删除
  1. 22
    2
      web/app/install/installForm.tsx

+ 22
- 2
web/app/install/installForm.tsx 查看文件

@@ -14,7 +14,7 @@ import Loading from '../components/base/loading'
import classNames from '@/utils/classnames'
import Button from '@/app/components/base/button'

import { fetchInitValidateStatus, fetchSetupStatus, setup } from '@/service/common'
import { fetchInitValidateStatus, fetchSetupStatus, login, setup } from '@/service/common'
import type { InitValidateStatusResponse, SetupStatusResponse } from '@/models/common'
import useDocumentTitle from '@/hooks/use-document-title'
import { useDocLink } from '@/context/i18n'
@@ -54,12 +54,32 @@ const InstallForm = () => {
})

const onSubmit: SubmitHandler<AccountFormValues> = async (data) => {
// First, setup the admin account
await setup({
body: {
...data,
},
})
router.push('/signin')

// Then, automatically login with the same credentials
const loginRes = await login({
url: '/login',
body: {
email: data.email,
password: data.password,
},
})

// Store tokens and redirect to apps if login successful
if (loginRes.result === 'success') {
localStorage.setItem('console_token', loginRes.data.access_token)
localStorage.setItem('refresh_token', loginRes.data.refresh_token)
router.replace('/apps')
}
else {
// Fallback to signin page if auto-login fails
router.replace('/signin')
}
}

const handleSetting = async () => {

Loading…
取消
儲存