From 09d44cc9eafe4bcf3d192bf0a0bf776a2ebd8382 Mon Sep 17 00:00:00 2001 From: SelfhostedPro Date: Thu, 18 Feb 2021 20:14:12 -0800 Subject: [PATCH 1/2] fix user schema to include auth status --- backend/api/db/schemas/users.py | 5 +++-- backend/api/routers/users.py | 2 +- frontend/src/App.vue | 3 ++- frontend/src/components/auth/LoginForm.vue | 6 +++--- frontend/src/store/modules/auth.js | 4 +++- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/backend/api/db/schemas/users.py b/backend/api/db/schemas/users.py index 246f5ace..1037347b 100644 --- a/backend/api/db/schemas/users.py +++ b/backend/api/db/schemas/users.py @@ -1,6 +1,6 @@ from pydantic import BaseModel from uuid import UUID -from typing import Union +from typing import Union, Optional class UserBase(BaseModel): @@ -14,6 +14,7 @@ class UserCreate(UserBase): class User(UserBase): id: Union[int, str, UUID] is_active: bool + authDisabled: Optional[bool] class Config: - orm_mode = True + orm_mode = True \ No newline at end of file diff --git a/backend/api/routers/users.py b/backend/api/routers/users.py index 73b15aa6..480a6ee9 100644 --- a/backend/api/routers/users.py +++ b/backend/api/routers/users.py @@ -63,7 +63,7 @@ def get_user(db: Session = Depends(get_db), Authorize: AuthJWT = Depends()): auth_check(Authorize) auth_setting = str(settings.DISABLE_AUTH) if auth_setting.lower() == "true": - current_user = models.User + current_user = schemas.User current_user.authDisabled = True current_user.id = 0 current_user.username = "user" diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 930be393..85226b87 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -1,6 +1,6 @@