增加验证码开启关闭配置

super_sign_new
youngS 4 years ago
parent d5c42cc769
commit a0dba04bf2
  1. 10
      fir_client/src/components/FirLogin.vue
  2. 14
      fir_client/src/components/FirRegist.vue
  3. 20
      fir_client/src/components/FirUserProfileInfo.vue
  4. 38
      fir_ser/api/views/login.py
  5. 2
      fir_ser/fir_ser/settings.py

@ -36,7 +36,7 @@
<el-input v-model="form.password" prefix-icon="el-icon-lock" placeholder="密码"
show-password></el-input>
</el-form-item>
<el-form-item style="height: 40px">
<el-form-item style="height: 40px" v-if="cptch.cptch_image">
<el-row style="height: 40px">
<el-col :span="16">
<el-input placeholder="请输入验证码" v-model="form.authcode" maxlength="6" @keyup.enter.native="onSubmit"></el-input>
@ -96,7 +96,11 @@
let password = this.form.password;
let authcode = this.form.authcode;
let login_type = 'up';
if (authcode.length === this.cptch.length) {
let cptch_flag= authcode.length === this.cptch.length;
if(this.cptch.cptch_key === '' || !this.cptch.cptch_key){
cptch_flag = true
}
if (cptch_flag) {
if (this.activeName === "username") {
if (email.length < 6) {
@ -166,7 +170,7 @@
} else {
this.$message({
message: '请输入正确的邮箱地址',
message: '密码长度过短',
type: 'warning'
});
}

@ -26,7 +26,7 @@
clearable></el-input>
</el-form-item>
<el-form-item style="height: 40px">
<el-form-item style="height: 40px" v-if="cptch.cptch_image">
<el-row style="height: 40px">
<el-col :span="16">
<el-input placeholder="请输入图片验证码" v-model="form.authcode" maxlength="6"></el-input>
@ -159,7 +159,11 @@
act = 'email'
}
let authcode = this.form.authcode;
if (authcode.length === this.cptch.length) {
let cptch_flag= authcode.length === this.cptch.length;
if(this.cptch.cptch_key === '' || !this.cptch.cptch_key){
cptch_flag = true
}
if (cptch_flag) {
let picode = {
"authcode": authcode,
"cptch_key": this.cptch.cptch_key,
@ -238,7 +242,11 @@
return
}
let authcode = this.form.authcode;
if (authcode.length === this.cptch.length) {
let cptch_flag= authcode.length === this.cptch.length;
if(this.cptch.cptch_key === '' || !this.cptch.cptch_key){
cptch_flag = true
}
if (cptch_flag) {
if (password === password2 && password.length >= 6) {
registerFun(data => {
if (data.code === 1000) {

@ -44,7 +44,7 @@
</el-row>
</el-form-item>
<el-form-item style="height: 40px" v-if="editphone === true">
<el-form-item style="height: 40px" v-if="editphone === true && cptch.cptch_image">
<el-row style="height: 40px" :gutter="10">
<el-col :span="11">
<el-input placeholder="请输入图片验证码" v-model="userinfo.authcode" maxlength="6"></el-input>
@ -96,7 +96,7 @@
</el-form-item>
<el-form-item style="height: 40px" v-if="editemail === true">
<el-form-item style="height: 40px" v-if="editemail === true && cptch.cptch_image">
<el-row style="height: 40px" :gutter="10">
<el-col :span="11">
<el-input placeholder="请输入图片验证码" v-model="userinfo.authcode" maxlength="6"></el-input>
@ -192,7 +192,7 @@
editdomain_name: false,
edituser_name: false,
editposition: false,
cptch: '',
cptch: {"cptch_image": '', "cptch_key": '', "length": 8},
}
}, methods: {
get_auth_code() {
@ -254,23 +254,9 @@
userinfos(data => {
if (data.code === 1000) {
// let phonenumber = null;
// if (data.data.sms_code) {
// phonenumber = this.userinfo.mobile;
// this.$notify({
// title: '',
// message: ':' + data.data.sms_code,
// type: 'success'
// });
// }
this.userinfo = data.data;
this.$store.dispatch("doUserinfo", data.data);
this.orguserinfo = deepCopy(data.data);
// if (phonenumber) {
// this.userinfo.mobile = phonenumber;
// }
if (datainfo.data) {
this.$message.success("更新成功")
}

@ -176,7 +176,10 @@ class LoginView(APIView):
response = BaseResponse()
receive = request.data
username = receive.get("username", None)
is_valid = valid_captcha(receive.get("cptch_key", None), receive.get("authcode", None), username)
if LOGIN.get("captcha"):
is_valid = valid_captcha(receive.get("cptch_key", None), receive.get("authcode", None), username)
else:
is_valid = True
if is_valid:
login_type = receive.get("login_type", None)
if login_auth_failed("get", username):
@ -226,7 +229,8 @@ class LoginView(APIView):
def get(self, request):
response = BaseResponse()
response.data = {}
response.data = get_captcha()
if LOGIN.get("captcha"):
response.data = get_captcha()
response.data['login_type'] = get_login_type()
return Response(response.dict)
@ -294,7 +298,8 @@ class RegistView(APIView):
response.data = {}
allow_f = REGISTER.get("enable")
if allow_f:
response.data = get_captcha()
if REGISTER.get("captcha"):
response.data = get_captcha()
response.data['register_type'] = get_register_type()
response.data['enable'] = allow_f
return Response(response.dict)
@ -455,12 +460,14 @@ class AuthorizationView(APIView):
res.msg = "邀请码已失效"
return Response(res.dict)
if ext and valid_captcha(ext.get("cptch_key", None), ext.get("authcode", None), target):
pass
else:
res.code = 1008
res.msg = "图片验证码有误"
return Response(res.dict)
if REGISTER.get("captcha"):
is_valid = valid_captcha(ext.get("cptch_key", None), ext.get("authcode", None), target)
if ext and is_valid:
pass
else:
res.code = 1008
res.msg = "图片验证码有误"
return Response(res.dict)
res = CheckRegisterUerinfo(target, act, 'register')
@ -478,12 +485,13 @@ class ChangeAuthorizationView(APIView):
ext = request.query_params.get("ext", None)
if ext:
ext = json.loads(ext)
if ext and valid_captcha(ext.get("cptch_key", None), ext.get("authcode", None), target):
pass
else:
res.code = 1008
res.msg = "图片验证码有误"
return Response(res.dict)
if REGISTER.get("captcha"):
if ext and valid_captcha(ext.get("cptch_key", None), ext.get("authcode", None), target):
pass
else:
res.code = 1009
res.msg = "图片验证码有误"
return Response(res.dict)
res = CheckChangeUerinfo(target, act, 'change', request.user)
return Response(res.dict)

@ -171,6 +171,7 @@ REST_FRAMEWORK_EXTENSIONS = {
# 注册方式,如果启用sms或者email 需要配置 THIRD_PART_CONFIG.sender 信息
REGISTER = {
"enable": True,
"captcha": True, # 是否开启注册字母验证码
"register_type": {
'sms': False, # 短信注册
'email': True, # 邮件注册
@ -180,6 +181,7 @@ REGISTER = {
# 信息修改也会使用该配置
LOGIN = {
"captcha": True, # 是否开启登录字母验证码
"login_type": {
'sms': True, # 短信登录
'email': True, # 邮件登录

Loading…
Cancel
Save