diff --git a/api/controllers/console/setup.py b/api/controllers/console/setup.py index 4677a2075b..3724bcd254 100644 --- a/api/controllers/console/setup.py +++ b/api/controllers/console/setup.py @@ -19,15 +19,16 @@ from .wraps import only_edition_self_hosted class SetupApi(Resource): - @only_edition_self_hosted def get(self): - setup_status = get_setup_status() - if setup_status: - return { - 'step': 'finished', - 'setup_at': setup_status.setup_at.isoformat() - } - return {'step': 'not_start'} + if current_app.config['EDITION'] == 'SELF_HOSTED': + setup_status = get_setup_status() + if setup_status: + return { + 'step': 'finished', + 'setup_at': setup_status.setup_at.isoformat() + } + return {'step': 'not_start'} + return {'step': 'finished'} @only_edition_self_hosted def post(self): diff --git a/web/app/install/installForm.tsx b/web/app/install/installForm.tsx index b728478bb3..b951a9a8bd 100644 --- a/web/app/install/installForm.tsx +++ b/web/app/install/installForm.tsx @@ -1,13 +1,15 @@ 'use client' -import React from 'react' +import React, { useEffect } from 'react' import { useTranslation } from 'react-i18next' import Link from 'next/link' import { useRouter } from 'next/navigation' import { useContext } from 'use-context-selector' import Toast from '../components/base/toast' +import Loading from '../components/base/loading' import Button from '@/app/components/base/button' -import { setup } from '@/service/common' import I18n from '@/context/i18n' +import { fetchSetupStatus, setup } from '@/service/common' +import type { SetupStatusResponse } from '@/models/common' const validEmailReg = /^[\w\.-]+@([\w-]+\.)+[\w-]{2,}$/ const validPassword = /^(?=.*[a-zA-Z])(?=.*\d).{8,}$/ @@ -21,6 +23,8 @@ const InstallForm = () => { const [name, setName] = React.useState('') const [password, setPassword] = React.useState('') const [showPassword, setShowPassword] = React.useState(false) + const [loading, setLoading] = React.useState(true) + const showErrorMessage = (message: string) => { Toast.notify({ type: 'error', @@ -61,78 +65,90 @@ const InstallForm = () => { }) router.push('/signin') } + + useEffect(() => { + fetchSetupStatus().then((res: SetupStatusResponse) => { + if (res.step === 'finished') + window.location.href = '/signin' + else + setLoading(false) + }) + }, []) + return ( - <> -
+
{t('login.setAdminAccountDesc')}
-