Skip to content

Commit 763d8fe

Browse files
committed
Update the crud pwd
1 parent 194bf36 commit 763d8fe

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

backend/app/admin/crud/crud_user.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,8 @@ async def add_by_oauth2(self, db: AsyncSession, obj: AddOAuth2UserParam) -> None
8989
:param obj: 注册用户参数
9090
:return:
9191
"""
92-
salt = bcrypt.gensalt()
93-
obj.password = get_hash_password(obj.password, salt)
9492
dict_obj = obj.model_dump()
95-
dict_obj.update({'is_staff': True, 'salt': salt})
93+
dict_obj.update({'is_staff': True, 'salt': None})
9694
new_user = self.model(**dict_obj)
9795

9896
stmt = select(Role)
@@ -156,10 +154,12 @@ async def reset_password(self, db: AsyncSession, pk: int, new_pwd: str) -> int:
156154
157155
:param db: 数据库会话
158156
:param pk: 用户 ID
159-
:param new_pwd: 新密码(已加密)
157+
:param new_pwd: 新密码
160158
:return:
161159
"""
162-
return await self.update_model(db, pk, {'password': new_pwd})
160+
salt = bcrypt.gensalt()
161+
new_pwd = get_hash_password(new_pwd, salt)
162+
return await self.update_model(db, pk, {'password': new_pwd, 'salt': salt})
163163

164164
async def get_list(self, dept: int | None, username: str | None, phone: str | None, status: int | None) -> Select:
165165
"""

0 commit comments

Comments
 (0)