mirror of https://github.com/langgenius/dify.git
Merge branch 'main' into feat/memory-orchestration-fed
This commit is contained in:
commit
828b9c6a93
|
|
@ -29,8 +29,6 @@ from libs.token import (
|
|||
clear_access_token_from_cookie,
|
||||
clear_csrf_token_from_cookie,
|
||||
clear_refresh_token_from_cookie,
|
||||
extract_access_token,
|
||||
extract_csrf_token,
|
||||
set_access_token_to_cookie,
|
||||
set_csrf_token_to_cookie,
|
||||
set_refresh_token_to_cookie,
|
||||
|
|
@ -286,13 +284,3 @@ class RefreshTokenApi(Resource):
|
|||
return response
|
||||
except Exception as e:
|
||||
return {"result": "fail", "message": str(e)}, 401
|
||||
|
||||
|
||||
# this api helps frontend to check whether user is authenticated
|
||||
# TODO: remove in the future. frontend should redirect to login page by catching 401 status
|
||||
@console_ns.route("/login/status")
|
||||
class LoginStatus(Resource):
|
||||
def get(self):
|
||||
token = extract_access_token(request)
|
||||
csrf_token = extract_csrf_token(request)
|
||||
return {"logged_in": bool(token) and bool(csrf_token)}
|
||||
|
|
|
|||
|
|
@ -117,6 +117,15 @@ export type IOtherOptions = {
|
|||
onDataSourceNodeError?: IOnDataSourceNodeError
|
||||
}
|
||||
|
||||
function jumpTo(url: string) {
|
||||
if(!url)
|
||||
return
|
||||
const targetPath = new URL(url, globalThis.location.origin).pathname
|
||||
if(targetPath === globalThis.location.pathname)
|
||||
return
|
||||
globalThis.location.href = url
|
||||
}
|
||||
|
||||
function unicodeToChar(text: string) {
|
||||
if (!text)
|
||||
return ''
|
||||
|
|
@ -585,11 +594,11 @@ export const request = async<T>(url: string, options = {}, otherOptions?: IOther
|
|||
return Promise.reject(err)
|
||||
}
|
||||
if (code === 'not_init_validated' && IS_CE_EDITION) {
|
||||
globalThis.location.href = `${globalThis.location.origin}${basePath}/init`
|
||||
jumpTo(`${globalThis.location.origin}${basePath}/init`)
|
||||
return Promise.reject(err)
|
||||
}
|
||||
if (code === 'not_setup' && IS_CE_EDITION) {
|
||||
globalThis.location.href = `${globalThis.location.origin}${basePath}/install`
|
||||
jumpTo(`${globalThis.location.origin}${basePath}/install`)
|
||||
return Promise.reject(err)
|
||||
}
|
||||
|
||||
|
|
@ -598,15 +607,14 @@ export const request = async<T>(url: string, options = {}, otherOptions?: IOther
|
|||
if (refreshErr === null)
|
||||
return baseFetch<T>(url, options, otherOptionsForBaseFetch)
|
||||
if (location.pathname !== `${basePath}/signin` || !IS_CE_EDITION) {
|
||||
globalThis.location.href = loginUrl
|
||||
jumpTo(loginUrl)
|
||||
return Promise.reject(err)
|
||||
}
|
||||
if (!silent) {
|
||||
Toast.notify({ type: 'error', message })
|
||||
return Promise.reject(err)
|
||||
}
|
||||
if (globalThis.location.href !== loginUrl)
|
||||
globalThis.location.href = loginUrl
|
||||
jumpTo(loginUrl)
|
||||
return Promise.reject(err)
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
Loading…
Reference in New Issue