移除用户系统级角色,权限完全迁移至项目级管理
- 用户注册/创建不再需要选择角色,账号管理只管资料和状态 - 移除前后端所有系统级 role 字段的暴露,改用 is_admin 标识管理员 - PM(项目负责人)角色自动拥有全部项目权限且不可修改 - 系统管理员在项目中的成员身份不可被删除 - 管理界面全面美化 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -6,7 +6,6 @@ from typing import Literal, Optional
|
||||
from pydantic import BaseModel, ConfigDict, EmailStr, Field, field_validator
|
||||
|
||||
UserRole = Literal["PM", "CRA", "PV", "MEDICAL_REVIEW", "IMP", "QA", "ADMIN"]
|
||||
RegisterRole = Literal["PM", "CRA", "PV", "MEDICAL_REVIEW", "IMP"]
|
||||
UserStatus = Literal["PENDING", "ACTIVE", "REJECTED", "DISABLED"]
|
||||
|
||||
PASSWORD_REGEX = re.compile(r"^(?=.*[A-Za-z])(?=.*\d).{8,}$")
|
||||
@@ -16,7 +15,6 @@ class UserDisplay(BaseModel):
|
||||
id: uuid.UUID
|
||||
email: EmailStr
|
||||
full_name: str
|
||||
role: UserRole
|
||||
avatar_url: Optional[str] = None
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
@@ -39,7 +37,6 @@ class UserRegisterRequest(_PasswordValidator):
|
||||
password: str = Field(min_length=8, max_length=72)
|
||||
email: EmailStr
|
||||
full_name: str = Field(min_length=1)
|
||||
role: RegisterRole
|
||||
clinical_department: str = Field(min_length=1)
|
||||
|
||||
|
||||
@@ -47,7 +44,6 @@ class UserCreate(_PasswordValidator):
|
||||
password: str = Field(min_length=8, max_length=72)
|
||||
email: EmailStr
|
||||
full_name: str = Field(min_length=1)
|
||||
role: UserRole
|
||||
clinical_department: str = Field(min_length=1)
|
||||
status: UserStatus = "ACTIVE"
|
||||
|
||||
@@ -57,10 +53,10 @@ class UserRead(BaseModel):
|
||||
email: EmailStr
|
||||
username: str
|
||||
full_name: str
|
||||
role: UserRole
|
||||
clinical_department: str
|
||||
status: UserStatus
|
||||
is_active: bool
|
||||
is_admin: bool = False
|
||||
created_at: datetime
|
||||
approved_at: Optional[datetime] = None
|
||||
approved_by: Optional[uuid.UUID] = None
|
||||
@@ -72,7 +68,6 @@ class UserRead(BaseModel):
|
||||
class UserUpdate(_PasswordValidator):
|
||||
email: Optional[EmailStr] = None
|
||||
full_name: Optional[str] = None
|
||||
role: Optional[UserRole] = None
|
||||
clinical_department: Optional[str] = None
|
||||
status: Optional[UserStatus] = None
|
||||
password: Optional[str] = None
|
||||
|
||||
Reference in New Issue
Block a user