增加用户名控制登录

dependabot/npm_and_yarn/fir_admin/tmpl-1.0.5
youngS 3 years ago
parent 5988e0e1a9
commit cf1267deb2
  1. 2
      fir_client/src/components/user/FirUserProfileInfo.vue
  2. 28
      fir_ser/api/views/login.py
  3. 2
      fir_ser/config.py

@ -81,7 +81,7 @@
</el-dialog> </el-dialog>
<el-form ref="form" :model="userinfo" label-width="90px"> <el-form ref="form" :model="userinfo" label-width="90px">
<el-form-item label="用户名"> <el-form-item label="用户名" v-if="userinfo && userinfo.login_type && userinfo.login_type.up">
<el-row :gutter="36"> <el-row :gutter="36">
<el-col :span="16"> <el-col :span="16">
<el-input v-model="userinfo.username" :readonly="edituser_name !== true" <el-input v-model="userinfo.username" :readonly="edituser_name !== true"

@ -425,7 +425,7 @@ class UserInfoView(APIView):
res = BaseResponse() res = BaseResponse()
serializer = UserInfoSerializer(request.user) serializer = UserInfoSerializer(request.user)
res.data = serializer.data res.data = serializer.data
res.data['login_type'] = get_login_type()
return Response(res.dict) return Response(res.dict)
def put(self, request): def put(self, request):
@ -466,22 +466,22 @@ class UserInfoView(APIView):
res.code = 1004 res.code = 1004
res.msg = "老密码校验失败" res.msg = "老密码校验失败"
else: else:
username = data.get("username", None) if get_login_type().get('up'):
if username and username != request.user.username: username = data.get("username", None)
if check_username_exists(username): if username and username != request.user.username:
res.msg = "用户名已经存在" if check_username_exists(username):
res.code = 1005 res.msg = "用户名已经存在"
logger.error(f"User {request.user} info save failed. username already exists") res.code = 1005
return Response(res.dict) logger.error(f"User {request.user} info save failed. username already exists")
if len(username) < 6: return Response(res.dict)
res.msg = "用户名至少6位" if len(username) < 6:
res.code = 1006 res.msg = "用户名至少6位"
return Response(res.dict) res.code = 1006
return Response(res.dict)
request.user.username = data.get("username", request.user.username)
request.user.job = data.get("job", request.user.job) request.user.job = data.get("job", request.user.job)
request.user.first_name = data.get("first_name", request.user.first_name) request.user.first_name = data.get("first_name", request.user.first_name)
request.user.username = data.get("username", request.user.username)
sms_token = data.get("auth_token", None) sms_token = data.get("auth_token", None)
if sms_token: if sms_token:
act = data.get("act", None) act = data.get("act", None)

@ -106,7 +106,7 @@ class AUTHCONF(object):
"login_type": { "login_type": {
'sms': True, # 短信登录 'sms': True, # 短信登录
'email': True, # 邮件登录 'email': True, # 邮件登录
'up': True, # 密码登录 'up': False, # 密码登录
} }
} }

Loading…
Cancel
Save