feat: remove enum UserValidate
This commit is contained in:
@@ -8,7 +8,7 @@ from starlette import status
|
||||
from starlette.requests import Request
|
||||
|
||||
from app.config.env import env
|
||||
from app.model.UserModel import RegistryUser, UserModel, UserValidate, PublicUser, UserService
|
||||
from app.model.UserModel import RegistryUser, UserModel, PublicUser, UserService
|
||||
from app.utils.CrpyUtils import CryptUtils, TokenInfo
|
||||
from app.utils.db_utils import AsyncSessionDep
|
||||
from app.utils.next_id import next_id
|
||||
@@ -48,7 +48,7 @@ def add_user_route(app: FastAPI):
|
||||
email=registry_user.email,
|
||||
full_name=registry_user.full_name,
|
||||
hash_password=hash_password,
|
||||
valid=UserValidate.N,
|
||||
valid='N',
|
||||
)
|
||||
user.id = await next_id()
|
||||
session.add(user)
|
||||
@@ -85,7 +85,7 @@ def add_user_route(app: FastAPI):
|
||||
if not item_cls:
|
||||
return {"result": None, "error": f"用户 {username} 不存在"}
|
||||
|
||||
item_cls.valid = UserValidate.Y
|
||||
item_cls.valid = 'Y'
|
||||
session.add(item_cls)
|
||||
await session.commit()
|
||||
await session.refresh(item_cls)
|
||||
@@ -168,7 +168,7 @@ async def authenticate_user(session: AsyncSessionDep, username: str, password: s
|
||||
if not item_cls:
|
||||
return None
|
||||
|
||||
if item_cls.valid != UserValidate.Y:
|
||||
if item_cls.valid != 'Y':
|
||||
return None
|
||||
|
||||
if not CryptUtils.verify_password(password, item_cls.hash_password):
|
||||
|
||||
@@ -11,17 +11,12 @@ from app.utils.create_module_service import create_model_service
|
||||
from app.utils.redis_utils import remove_redis_cache
|
||||
|
||||
|
||||
class UserValidate(str, Enum):
|
||||
Y = 'Y'
|
||||
N = 'N'
|
||||
|
||||
|
||||
# 公共的,也是最后返回给前端的一个用户信息数据类型
|
||||
class PublicUser(BasicModel):
|
||||
username: str = Field(..., description="用户名")
|
||||
email: str = Field(..., description="邮箱")
|
||||
full_name: str = Field(..., description="用户全名")
|
||||
valid: UserValidate = Field(default=UserValidate.N, description="用户账号是否已经激活")
|
||||
valid: str = Field(default='N', description="用户账号是否已经激活")
|
||||
|
||||
|
||||
# 注册的时候,客户端传入的用户信息,需要包含这个明文密码字段
|
||||
|
||||
Reference in New Issue
Block a user