Skip to content

Commit b559a74

Browse files
authored
Add update support for user email and phone (#742)
1 parent 83dcdbe commit b559a74

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

backend/app/admin/schema/user.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from datetime import datetime
44
from typing import Any
55

6-
from pydantic import ConfigDict, EmailStr, Field, HttpUrl, model_validator
6+
from pydantic import ConfigDict, Field, HttpUrl, model_validator
77
from typing_extensions import Self
88

99
from backend.app.admin.schema.dept import GetDeptDetail
@@ -16,7 +16,7 @@ class AuthSchemaBase(SchemaBase):
1616
"""用户认证基础模型"""
1717

1818
username: str = Field(description='用户名')
19-
password: str | None = Field(description='密码')
19+
password: str = Field(description='密码')
2020

2121

2222
class AuthLoginParam(AuthSchemaBase):
@@ -28,16 +28,19 @@ class AuthLoginParam(AuthSchemaBase):
2828
class AddUserParam(AuthSchemaBase):
2929
"""添加用户参数"""
3030

31+
nickname: str | None = Field(None, description='昵称')
32+
email: CustomEmailStr | None = Field(None, description='邮箱')
33+
phone: CustomPhoneNumber | None = Field(None, description='手机号码')
3134
dept_id: int = Field(description='部门 ID')
3235
roles: list[int] = Field(description='角色 ID 列表')
33-
nickname: str | None = Field(None, description='昵称')
3436

3537

3638
class AddOAuth2UserParam(AuthSchemaBase):
3739
"""添加 OAuth2 用户参数"""
3840

41+
password: str | None = Field(None, description='密码')
3942
nickname: str | None = Field(None, description='昵称')
40-
email: EmailStr = Field(description='邮箱')
43+
email: CustomEmailStr | None = Field(None, description='邮箱')
4144
avatar: HttpUrl | None = Field(None, description='头像地址')
4245

4346

@@ -56,6 +59,8 @@ class UserInfoSchemaBase(SchemaBase):
5659
username: str = Field(description='用户名')
5760
nickname: str = Field(description='昵称')
5861
avatar: HttpUrl | None = Field(None, description='头像地址')
62+
email: CustomEmailStr | None = Field(None, description='邮箱')
63+
phone: CustomPhoneNumber | None = Field(None, description='手机号')
5964

6065

6166
class UpdateUserParam(UserInfoSchemaBase):
@@ -72,8 +77,6 @@ class GetUserInfoDetail(UserInfoSchemaBase):
7277
dept_id: int | None = Field(None, description='部门 ID')
7378
id: int = Field(description='用户 ID')
7479
uuid: str = Field(description='用户 UUID')
75-
email: CustomEmailStr | None = Field(None, description='邮箱')
76-
phone: CustomPhoneNumber | None = Field(None, description='手机号')
7780
status: StatusType = Field(description='状态')
7881
is_superuser: bool = Field(description='是否超级管理员')
7982
is_staff: bool = Field(description='是否管理员')

backend/app/admin/service/auth_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class AuthService:
3333
"""认证服务类"""
3434

3535
@staticmethod
36-
async def user_verify(db: AsyncSession, username: str, password: str | None) -> User:
36+
async def user_verify(db: AsyncSession, username: str, password: str) -> User:
3737
"""
3838
验证用户名和密码
3939

0 commit comments

Comments
 (0)