From 3bf7a5a3a34742372647fc0823f072ceea43c925 Mon Sep 17 00:00:00 2001 From: ktianc Date: Sun, 5 Nov 2023 14:50:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=8F=9C=E5=8D=95=E5=89=8D?= =?UTF-8?q?=E7=AB=AF=E7=BB=84=E4=BB=B6=E5=AD=97=E6=AE=B5=E9=95=BF=E5=BA=A6?= =?UTF-8?q?=EF=BC=8C=E4=BB=A5=E5=8F=8A=E7=94=A8=E6=88=B7=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E7=B1=BB=E6=96=B9=E6=B3=95=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kinit-api/application/settings.py | 2 +- kinit-api/apps/vadmin/auth/models/menu.py | 4 +++- kinit-api/apps/vadmin/auth/models/user.py | 15 +++++++++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/kinit-api/application/settings.py b/kinit-api/application/settings.py index 5b408e31..6a558ff1 100644 --- a/kinit-api/application/settings.py +++ b/kinit-api/application/settings.py @@ -11,7 +11,7 @@ """ 系统版本 """ -VERSION = "3.2.1" +VERSION = "3.2.2" """安全警告: 不要在生产中打开调试运行!""" DEBUG = False diff --git a/kinit-api/apps/vadmin/auth/models/menu.py b/kinit-api/apps/vadmin/auth/models/menu.py index 74fc228f..fa6156a8 100644 --- a/kinit-api/apps/vadmin/auth/models/menu.py +++ b/kinit-api/apps/vadmin/auth/models/menu.py @@ -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,则不会被 缓存(默认 false)", diff --git a/kinit-api/apps/vadmin/auth/models/user.py b/kinit-api/apps/vadmin/auth/models/user.py index cb85ff0e..9e3de129 100644 --- a/kinit-api/apps/vadmin/auth/models/user.py +++ b/kinit-api/apps/vadmin/auth/models/user.py @@ -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])