Skip to content

Commit b9f47dd

Browse files
perf: Users from third-party platforms are prohibited from using the default login
1 parent 2248829 commit b9f47dd

File tree

5 files changed

+9
-3
lines changed

5 files changed

+9
-3
lines changed

backend/apps/system/api/login.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ async def local_login(
2828
raise HTTPException(status_code=400, detail=trans('i18n_login.no_associated_ws', msg = trans('i18n_concat_admin')))
2929
if user.status != 1:
3030
raise HTTPException(status_code=400, detail=trans('i18n_login.user_disable', msg = trans('i18n_concat_admin')))
31+
if user.origin is not None and user.origin != 0:
32+
raise HTTPException(status_code=400, detail=trans('i18n_login.origin_error'))
3133
access_token_expires = timedelta(minutes=settings.ACCESS_TOKEN_EXPIRE_MINUTES)
3234
user_dict = user.to_dict()
3335
return Token(access_token=create_access_token(

backend/apps/system/schemas/system_schema.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class BaseUserDTO(BaseUser, BaseCreatorDTO):
3434
language: str = Field(pattern=r"^(zh-CN|en|ko-KR)$", default="zh-CN", description="用户语言")
3535
password: str
3636
status: int = 1
37+
origin: int = 0
3738

3839
def to_dict(self):
3940
return {

backend/locales/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"i18n_login": {
1212
"account_pwd_error": "Incorrect account or password!",
1313
"no_associated_ws": "No associated workspace, {msg}",
14-
"user_disable": "Account is disabled, {msg}"
14+
"user_disable": "Account is disabled, {msg}",
15+
"origin_error": "Invalid login method"
1516
},
1617
"i18n_user": {
1718
"account": "Account",

backend/locales/ko-KR.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"i18n_login": {
1212
"account_pwd_error": "계정 또는 비밀번호가 잘못되었습니다!",
1313
"no_associated_ws": "연결된 작업 공간이 없습니다, {msg}",
14-
"user_disable": "계정이 비활성화되었습니다, {msg}"
14+
"user_disable": "계정이 비활성화되었습니다, {msg}",
15+
"origin_error": "잘못된 로그인 방식입니다"
1516
},
1617
"i18n_user": {
1718
"account": "계정",

backend/locales/zh-CN.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"i18n_login": {
1212
"account_pwd_error": "账号或密码错误!",
1313
"no_associated_ws": "没有关联的工作空间,{msg}",
14-
"user_disable": "账号已禁用,{msg}"
14+
"user_disable": "账号已禁用,{msg}",
15+
"origin_error": "登录方式错误"
1516
},
1617
"i18n_user": {
1718
"account": "账号",

0 commit comments

Comments
 (0)