@@ -14,7 +14,7 @@ import Loading from '../components/base/loading'
14
14
import classNames from '@/utils/classnames'
15
15
import Button from '@/app/components/base/button'
16
16
17
- import { fetchInitValidateStatus , fetchSetupStatus , setup } from '@/service/common'
17
+ import { fetchInitValidateStatus , fetchSetupStatus , login , setup } from '@/service/common'
18
18
import type { InitValidateStatusResponse , SetupStatusResponse } from '@/models/common'
19
19
import useDocumentTitle from '@/hooks/use-document-title'
20
20
import { useDocLink } from '@/context/i18n'
@@ -54,12 +54,32 @@ const InstallForm = () => {
54
54
} )
55
55
56
56
const onSubmit : SubmitHandler < AccountFormValues > = async ( data ) => {
57
+ // First, setup the admin account
57
58
await setup ( {
58
59
body : {
59
60
...data ,
60
61
} ,
61
62
} )
62
- router . push ( '/signin' )
63
+
64
+ // Then, automatically login with the same credentials
65
+ const loginRes = await login ( {
66
+ url : '/login' ,
67
+ body : {
68
+ email : data . email ,
69
+ password : data . password ,
70
+ } ,
71
+ } )
72
+
73
+ // Store tokens and redirect to apps if login successful
74
+ if ( loginRes . result === 'success' ) {
75
+ localStorage . setItem ( 'console_token' , loginRes . data . access_token )
76
+ localStorage . setItem ( 'refresh_token' , loginRes . data . refresh_token )
77
+ router . replace ( '/apps' )
78
+ }
79
+ else {
80
+ // Fallback to signin page if auto-login fails
81
+ router . replace ( '/signin' )
82
+ }
63
83
}
64
84
65
85
const handleSetting = async ( ) => {
0 commit comments