mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-12 20:29:02 +08:00
fix: old webapp url still valid (#1643)
This commit is contained in:
parent
c21e2063fe
commit
cf0ba794d7
@ -40,7 +40,7 @@ def decode_jwt_token():
|
|||||||
site = db.session.query(Site).filter(Site.code == app_code).first()
|
site = db.session.query(Site).filter(Site.code == app_code).first()
|
||||||
if not app_model:
|
if not app_model:
|
||||||
raise NotFound()
|
raise NotFound()
|
||||||
if not app_code and not site:
|
if not app_code or not site:
|
||||||
raise Unauthorized('Site URL is no longer valid.')
|
raise Unauthorized('Site URL is no longer valid.')
|
||||||
if app_model.enable_site is False:
|
if app_model.enable_site is False:
|
||||||
raise Unauthorized('Site is disabled.')
|
raise Unauthorized('Site is disabled.')
|
||||||
|
@ -237,29 +237,24 @@ const baseFetch = <T>(
|
|||||||
switch (res.status) {
|
switch (res.status) {
|
||||||
case 401: {
|
case 401: {
|
||||||
if (isPublicAPI) {
|
if (isPublicAPI) {
|
||||||
Toast.notify({ type: 'error', message: 'Invalid token' })
|
return bodyJson.then((data: ResponseError) => {
|
||||||
return bodyJson.then((data: T) => Promise.reject(data))
|
Toast.notify({ type: 'error', message: data.message })
|
||||||
|
return Promise.reject(data)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
const loginUrl = `${globalThis.location.origin}/signin`
|
const loginUrl = `${globalThis.location.origin}/signin`
|
||||||
if (IS_CE_EDITION) {
|
|
||||||
bodyJson.then((data: ResponseError) => {
|
bodyJson.then((data: ResponseError) => {
|
||||||
if (data.code === 'not_setup') {
|
if (data.code === 'not_setup' && IS_CE_EDITION)
|
||||||
globalThis.location.href = `${globalThis.location.origin}/install`
|
globalThis.location.href = `${globalThis.location.origin}/install`
|
||||||
}
|
else if (location.pathname !== '/signin' || !IS_CE_EDITION)
|
||||||
else {
|
globalThis.location.href = loginUrl
|
||||||
if (location.pathname === '/signin') {
|
else
|
||||||
bodyJson.then((data: ResponseError) => {
|
|
||||||
Toast.notify({ type: 'error', message: data.message })
|
Toast.notify({ type: 'error', message: data.message })
|
||||||
})
|
}).catch(() => {
|
||||||
}
|
// Handle any other errors
|
||||||
else {
|
|
||||||
globalThis.location.href = loginUrl
|
globalThis.location.href = loginUrl
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
return Promise.reject(Error('Unauthorized'))
|
|
||||||
}
|
|
||||||
globalThis.location.href = loginUrl
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 403:
|
case 403:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user