Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
6242e91a
Unverified
Commit
6242e91a
authored
Aug 07, 2023
by
Matri
Committed by
GitHub
Aug 07, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix: Install page redirects to signin if Dify finished setup. (#762)
parent
cc7b5d12
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
136 additions
and
114 deletions
+136
-114
setup.py
api/controllers/console/setup.py
+9
-8
installForm.tsx
web/app/install/installForm.tsx
+94
-78
page.tsx
web/app/install/page.tsx
+22
-26
common.ts
web/models/common.ts
+5
-0
common.ts
web/service/common.ts
+6
-2
No files found.
api/controllers/console/setup.py
View file @
6242e91a
...
@@ -19,8 +19,8 @@ from .wraps import only_edition_self_hosted
...
@@ -19,8 +19,8 @@ from .wraps import only_edition_self_hosted
class
SetupApi
(
Resource
):
class
SetupApi
(
Resource
):
@
only_edition_self_hosted
def
get
(
self
):
def
get
(
self
):
if
current_app
.
config
[
'EDITION'
]
==
'SELF_HOSTED'
:
setup_status
=
get_setup_status
()
setup_status
=
get_setup_status
()
if
setup_status
:
if
setup_status
:
return
{
return
{
...
@@ -28,6 +28,7 @@ class SetupApi(Resource):
...
@@ -28,6 +28,7 @@ class SetupApi(Resource):
'setup_at'
:
setup_status
.
setup_at
.
isoformat
()
'setup_at'
:
setup_status
.
setup_at
.
isoformat
()
}
}
return
{
'step'
:
'not_start'
}
return
{
'step'
:
'not_start'
}
return
{
'step'
:
'finished'
}
@
only_edition_self_hosted
@
only_edition_self_hosted
def
post
(
self
):
def
post
(
self
):
...
...
web/app/install/installForm.tsx
View file @
6242e91a
'use client'
'use client'
import
React
from
'react'
import
React
,
{
useEffect
}
from
'react'
import
{
useTranslation
}
from
'react-i18next'
import
{
useTranslation
}
from
'react-i18next'
import
Link
from
'next/link'
import
Link
from
'next/link'
import
{
useRouter
}
from
'next/navigation'
import
{
useRouter
}
from
'next/navigation'
import
{
useContext
}
from
'use-context-selector'
import
{
useContext
}
from
'use-context-selector'
import
Toast
from
'../components/base/toast'
import
Toast
from
'../components/base/toast'
import
Loading
from
'../components/base/loading'
import
Button
from
'@/app/components/base/button'
import
Button
from
'@/app/components/base/button'
import
{
setup
}
from
'@/service/common'
import
I18n
from
'@/context/i18n'
import
I18n
from
'@/context/i18n'
import
{
fetchSetupStatus
,
setup
}
from
'@/service/common'
import
type
{
SetupStatusResponse
}
from
'@/models/common'
const
validEmailReg
=
/^
[\w\.
-
]
+@
([\w
-
]
+
\.)
+
[\w
-
]{2,}
$/
const
validEmailReg
=
/^
[\w\.
-
]
+@
([\w
-
]
+
\.)
+
[\w
-
]{2,}
$/
const
validPassword
=
/^
(?=
.*
[
a-zA-Z
])(?=
.*
\d)
.
{8,}
$/
const
validPassword
=
/^
(?=
.*
[
a-zA-Z
])(?=
.*
\d)
.
{8,}
$/
...
@@ -21,6 +23,8 @@ const InstallForm = () => {
...
@@ -21,6 +23,8 @@ const InstallForm = () => {
const
[
name
,
setName
]
=
React
.
useState
(
''
)
const
[
name
,
setName
]
=
React
.
useState
(
''
)
const
[
password
,
setPassword
]
=
React
.
useState
(
''
)
const
[
password
,
setPassword
]
=
React
.
useState
(
''
)
const
[
showPassword
,
setShowPassword
]
=
React
.
useState
(
false
)
const
[
showPassword
,
setShowPassword
]
=
React
.
useState
(
false
)
const
[
loading
,
setLoading
]
=
React
.
useState
(
true
)
const
showErrorMessage
=
(
message
:
string
)
=>
{
const
showErrorMessage
=
(
message
:
string
)
=>
{
Toast
.
notify
({
Toast
.
notify
({
type
:
'error'
,
type
:
'error'
,
...
@@ -61,8 +65,20 @@ const InstallForm = () => {
...
@@ -61,8 +65,20 @@ const InstallForm = () => {
})
})
router
.
push
(
'/signin'
)
router
.
push
(
'/signin'
)
}
}
useEffect
(()
=>
{
fetchSetupStatus
().
then
((
res
:
SetupStatusResponse
)
=>
{
if
(
res
.
step
===
'finished'
)
window
.
location
.
href
=
'/signin'
else
setLoading
(
false
)
})
},
[])
return
(
return
(
<>
loading
?
<
Loading
/>
:
<>
<
div
className=
"sm:mx-auto sm:w-full sm:max-w-md"
>
<
div
className=
"sm:mx-auto sm:w-full sm:max-w-md"
>
<
h2
className=
"text-[32px] font-bold text-gray-900"
>
{
t
(
'login.setAdminAccount'
)
}
</
h2
>
<
h2
className=
"text-[32px] font-bold text-gray-900"
>
{
t
(
'login.setAdminAccount'
)
}
</
h2
>
<
p
className=
'
<
p
className=
'
...
...
web/app/install/page.tsx
View file @
6242e91a
import
React
from
'react'
import
React
from
'react'
import
InstallForm
from
'./installForm
'
import
classNames
from
'classnames
'
import
Header
from
'../signin/_header'
import
Header
from
'../signin/_header'
import
style
from
'../signin/page.module.css'
import
style
from
'../signin/page.module.css'
import
classNames
from
'classnames'
import
InstallForm
from
'./installForm'
const
SignIn
=
()
=>
{
const
Install
=
()
=>
{
return
(
return
(
<>
<
div
className=
{
classNames
(
<
div
className=
{
classNames
(
style
.
background
,
style
.
background
,
'flex w-full min-h-screen'
,
'flex w-full min-h-screen'
,
'p-4 lg:p-8'
,
'p-4 lg:p-8'
,
'gap-x-20'
,
'gap-x-20'
,
'justify-center lg:justify-start'
'justify-center lg:justify-start'
,
)
}
>
)
}
>
<
div
className=
{
<
div
className=
{
classNames
(
classNames
(
'flex w-full flex-col bg-white shadow rounded-2xl shrink-0'
,
'flex w-full flex-col bg-white shadow rounded-2xl shrink-0'
,
'md:w-[608px] space-between'
'md:w-[608px] space-between'
,
)
)
}
>
}
>
<
Header
/>
<
Header
/>
...
@@ -28,9 +26,7 @@ const SignIn = () => {
...
@@ -28,9 +26,7 @@ const SignIn = () => {
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
</>
)
)
}
}
export
default
SignIn
export
default
Install
web/models/common.ts
View file @
6242e91a
...
@@ -6,6 +6,11 @@ export type OauthResponse = {
...
@@ -6,6 +6,11 @@ export type OauthResponse = {
redirect_url
:
string
redirect_url
:
string
}
}
export
type
SetupStatusResponse
=
{
step
:
'finished'
|
'not_started'
setup_at
?:
Date
}
export
type
UserProfileResponse
=
{
export
type
UserProfileResponse
=
{
id
:
string
id
:
string
name
:
string
name
:
string
...
...
web/service/common.ts
View file @
6242e91a
...
@@ -3,8 +3,8 @@ import { del, get, patch, post, put } from './base'
...
@@ -3,8 +3,8 @@ import { del, get, patch, post, put } from './base'
import
type
{
import
type
{
AccountIntegrate
,
CommonResponse
,
DataSourceNotion
,
AccountIntegrate
,
CommonResponse
,
DataSourceNotion
,
IWorkspace
,
LangGeniusVersionResponse
,
Member
,
IWorkspace
,
LangGeniusVersionResponse
,
Member
,
OauthResponse
,
PluginProvider
,
Provider
,
ProviderAnthropicToken
,
ProviderAzureToken
,
TenantInfoResponse
,
OauthResponse
,
PluginProvider
,
Provider
,
ProviderAnthropicToken
,
ProviderAzureToken
,
UserProfileOriginResponse
,
SetupStatusResponse
,
TenantInfoResponse
,
UserProfileOriginResponse
,
}
from
'@/models/common'
}
from
'@/models/common'
import
type
{
import
type
{
UpdateOpenAIKeyResponse
,
UpdateOpenAIKeyResponse
,
...
@@ -19,6 +19,10 @@ export const setup: Fetcher<CommonResponse, { body: Record<string, any> }> = ({
...
@@ -19,6 +19,10 @@ export const setup: Fetcher<CommonResponse, { body: Record<string, any> }> = ({
return
post
(
'/setup'
,
{
body
})
as
Promise
<
CommonResponse
>
return
post
(
'/setup'
,
{
body
})
as
Promise
<
CommonResponse
>
}
}
export
const
fetchSetupStatus
=
()
=>
{
return
get
(
'/setup'
)
as
Promise
<
SetupStatusResponse
>
}
export
const
fetchUserProfile
:
Fetcher
<
UserProfileOriginResponse
,
{
url
:
string
;
params
:
Record
<
string
,
any
>
}
>
=
({
url
,
params
})
=>
{
export
const
fetchUserProfile
:
Fetcher
<
UserProfileOriginResponse
,
{
url
:
string
;
params
:
Record
<
string
,
any
>
}
>
=
({
url
,
params
})
=>
{
return
get
(
url
,
params
,
{
needAllResponseContent
:
true
})
as
Promise
<
UserProfileOriginResponse
>
return
get
(
url
,
params
,
{
needAllResponseContent
:
true
})
as
Promise
<
UserProfileOriginResponse
>
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment