更新菜单前端组件字段长度,以及用户模型类方法优化
This commit is contained in:
parent
08c681e608
commit
3bf7a5a3a3
@ -11,7 +11,7 @@ from fastapi.security import OAuth2PasswordBearer
|
||||
"""
|
||||
系统版本
|
||||
"""
|
||||
VERSION = "3.2.1"
|
||||
VERSION = "3.2.2"
|
||||
|
||||
"""安全警告: 不要在生产中打开调试运行!"""
|
||||
DEBUG = False
|
||||
|
@ -19,7 +19,7 @@ class VadminMenu(BaseModel):
|
||||
title: Mapped[str] = mapped_column(String(50), comment="名称")
|
||||
icon: Mapped[str | None] = mapped_column(String(50), comment="菜单图标")
|
||||
redirect: Mapped[str | None] = mapped_column(String(100), comment="重定向地址")
|
||||
component: Mapped[str | None] = mapped_column(String(50), comment="前端组件地址")
|
||||
component: Mapped[str | None] = mapped_column(String(255), comment="前端组件地址")
|
||||
path: Mapped[str | None] = mapped_column(String(50), comment="前端路由地址")
|
||||
disabled: Mapped[bool] = mapped_column(Boolean, default=False, comment="是否禁用")
|
||||
hidden: Mapped[bool] = mapped_column(Boolean, default=False, comment="是否隐藏")
|
||||
@ -31,6 +31,8 @@ class VadminMenu(BaseModel):
|
||||
comment="父菜单"
|
||||
)
|
||||
perms: Mapped[str | None] = mapped_column(String(50), comment="权限标识", unique=False, index=True)
|
||||
|
||||
"""以下属性主要用于补全前端路由属性,"""
|
||||
noCache: Mapped[bool] = mapped_column(
|
||||
Boolean,
|
||||
comment="如果设置为true,则不会被 <keep-alive> 缓存(默认 false)",
|
||||
|
@ -42,22 +42,29 @@ class VadminUser(BaseModel):
|
||||
|
||||
roles: Mapped[set[VadminRole]] = relationship(secondary=vadmin_auth_user_roles)
|
||||
|
||||
# generate hash password
|
||||
@staticmethod
|
||||
def get_password_hash(password: str) -> str:
|
||||
"""
|
||||
生成哈希密码
|
||||
:param password: 原始密码
|
||||
:return: 哈希密码
|
||||
"""
|
||||
return pwd_context.hash(password)
|
||||
|
||||
# verify login password
|
||||
@staticmethod
|
||||
def verify_password(password: str, hashed_password: str) -> bool:
|
||||
"""
|
||||
验证原始密码是否与哈希密码一致
|
||||
:param password: 原始密码
|
||||
:param hashed_password: 哈希密码
|
||||
:return:
|
||||
"""
|
||||
return pwd_context.verify(password, hashed_password)
|
||||
|
||||
def is_admin(self) -> bool:
|
||||
"""
|
||||
获取该用户是否拥有最高权限
|
||||
|
||||
以最高权限为准
|
||||
|
||||
:return:
|
||||
"""
|
||||
return any([i.is_admin for i in self.roles])
|
||||
|
Loading…
x
Reference in New Issue
Block a user