mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-12 18:29:04 +08:00
Feat/optimize login (#9642)
This commit is contained in:
parent
ceb2c4f3ef
commit
22bdfb7e56
@ -94,17 +94,15 @@ class OAuthCallback(Resource):
|
|||||||
account = _generate_account(provider, user_info)
|
account = _generate_account(provider, user_info)
|
||||||
except AccountNotFoundError:
|
except AccountNotFoundError:
|
||||||
return redirect(f"{dify_config.CONSOLE_WEB_URL}/signin?message=Account not found.")
|
return redirect(f"{dify_config.CONSOLE_WEB_URL}/signin?message=Account not found.")
|
||||||
except WorkSpaceNotFoundError:
|
except (WorkSpaceNotFoundError, WorkSpaceNotAllowedCreateError):
|
||||||
return redirect(f"{dify_config.CONSOLE_WEB_URL}/signin?message=Workspace not found.")
|
|
||||||
except WorkSpaceNotAllowedCreateError:
|
|
||||||
return redirect(
|
return redirect(
|
||||||
f"{dify_config.CONSOLE_WEB_URL}/signin"
|
f"{dify_config.CONSOLE_WEB_URL}/signin"
|
||||||
"?message=Workspace not found, please contact system admin to invite you to join in a workspace."
|
"?message=Workspace not found, please contact system admin to invite you to join in a workspace."
|
||||||
)
|
)
|
||||||
|
|
||||||
# Check account status
|
# Check account status
|
||||||
if account.status in {AccountStatus.BANNED.value, AccountStatus.CLOSED.value}:
|
if account.status == AccountStatus.BANNED.value:
|
||||||
return {"error": "Account is banned or closed."}, 403
|
return redirect(f"{dify_config.CONSOLE_WEB_URL}/signin?message=Account is banned.")
|
||||||
|
|
||||||
if account.status == AccountStatus.PENDING.value:
|
if account.status == AccountStatus.PENDING.value:
|
||||||
account.status = AccountStatus.ACTIVE.value
|
account.status = AccountStatus.ACTIVE.value
|
||||||
|
@ -98,8 +98,8 @@ class AccountService:
|
|||||||
if not account:
|
if not account:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if account.status in {AccountStatus.BANNED.value, AccountStatus.CLOSED.value}:
|
if account.status == AccountStatus.BANNED.value:
|
||||||
raise Unauthorized("Account is banned or closed.")
|
raise Unauthorized("Account is banned.")
|
||||||
|
|
||||||
current_tenant = TenantAccountJoin.query.filter_by(account_id=account.id, current=True).first()
|
current_tenant = TenantAccountJoin.query.filter_by(account_id=account.id, current=True).first()
|
||||||
if current_tenant:
|
if current_tenant:
|
||||||
@ -143,8 +143,8 @@ class AccountService:
|
|||||||
if not account:
|
if not account:
|
||||||
raise AccountNotFoundError()
|
raise AccountNotFoundError()
|
||||||
|
|
||||||
if account.status in {AccountStatus.BANNED.value, AccountStatus.CLOSED.value}:
|
if account.status == AccountStatus.BANNED.value:
|
||||||
raise AccountLoginError("Account is banned or closed.")
|
raise AccountLoginError("Account is banned.")
|
||||||
|
|
||||||
if password and invite_token and account.password is None:
|
if password and invite_token and account.password is None:
|
||||||
# if invite_token is valid, set password and password_salt
|
# if invite_token is valid, set password and password_salt
|
||||||
@ -408,8 +408,8 @@ class AccountService:
|
|||||||
if not account:
|
if not account:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if account.status in {AccountStatus.BANNED.value, AccountStatus.CLOSED.value}:
|
if account.status == AccountStatus.BANNED.value:
|
||||||
raise Unauthorized("Account is banned or closed.")
|
raise Unauthorized("Account is banned.")
|
||||||
|
|
||||||
return account
|
return account
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user