Skip to content

Commit

Permalink
更新菜单前端组件字段长度,以及用户模型类方法优化
Browse files Browse the repository at this point in the history
  • Loading branch information
ktianc committed Nov 5, 2023
1 parent 08c681e commit 3bf7a5a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion kinit-api/application/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"""
系统版本
"""
VERSION = "3.2.1"
VERSION = "3.2.2"

"""安全警告: 不要在生产中打开调试运行!"""
DEBUG = False
Expand Down
4 changes: 3 additions & 1 deletion kinit-api/apps/vadmin/auth/models/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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="是否隐藏")
Expand All @@ -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)",
Expand Down
15 changes: 11 additions & 4 deletions kinit-api/apps/vadmin/auth/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])

0 comments on commit 3bf7a5a

Please sign in to comment.