修复了 UserPassword 不存在的问题,修复了明文密码的问题
This commit is contained in:
@@ -509,11 +509,12 @@ class ModifyAdminUserView(APIView):
|
||||
if password:
|
||||
if len(password) < 6:
|
||||
return Response({'code': 400, 'msg': '密码至少6位'})
|
||||
target_user.password = password
|
||||
target_user.SetPassword(password)
|
||||
if erjimima:
|
||||
if len(erjimima) < 6:
|
||||
return Response({'code': 400, 'msg': '二级密码至少6位'})
|
||||
target_kefu.erjimima = erjimima # 假设二级密码也需要加密
|
||||
import bcrypt as _bcrypt
|
||||
target_kefu.erjimima = _bcrypt.hashpw(erjimima.encode('utf-8'), _bcrypt.gensalt(rounds=12)).decode('utf-8')
|
||||
target_user.save()
|
||||
target_kefu.save()
|
||||
return Response({'code': 0, 'msg': '修改成功'})
|
||||
@@ -602,10 +603,12 @@ class AddAdminUserView(APIView):
|
||||
user_main.SetPassword(password)
|
||||
user_main.save(update_fields=['UserPassword'])
|
||||
# 创建客服扩展表(后台用户扩展)
|
||||
import bcrypt as _bcrypt
|
||||
erjimima_hashed = _bcrypt.hashpw(erjimima.encode('utf-8'), _bcrypt.gensalt(rounds=12)).decode('utf-8')
|
||||
UserKefu.query.create(
|
||||
user=user_main,
|
||||
nicheng=nicheng,
|
||||
erjimima=erjimima,
|
||||
erjimima=erjimima_hashed,
|
||||
zhuangtai=1
|
||||
)
|
||||
# 分配客服角色
|
||||
|
||||
Reference in New Issue
Block a user