实名认证问题

v1.0.0
youngS 4 years ago
parent 227501d89c
commit e1a34c1fa8
  1. 29
      fir_client/src/components/user/FirUserProfileCertification.vue
  2. 18
      fir_client/src/components/user/FirUserProfileInfo.vue
  3. 23
      fir_ser/api/migrations/0045_auto_20210423_1645.py
  4. 18
      fir_ser/api/migrations/0046_auto_20210423_1650.py
  5. 6
      fir_ser/api/models.py
  6. 17
      fir_ser/api/views/login.py
  7. 8
      fir_ser/fir_ser/settings.py

@ -1,5 +1,5 @@
<template>
<div v-if="certification && !cert_edit_flag">
<div v-if="(certification || certification === 0) && !cert_edit_flag">
<el-form style="max-width: 400px">
<el-form-item>
<el-row>
@ -33,7 +33,7 @@
</el-col>
</el-row>
</el-form-item>
<el-form-item label="手机号码">
<el-form-item label="手机号码" v-if="certification.mobile">
<el-row :gutter="36">
<el-col :span="18">
<el-link :underline="false">{{ certification.mobile }}</el-link>
@ -100,7 +100,7 @@
</el-form-item>
<el-form-item label="手机号码">
<el-form-item label="手机号码" v-if="cptch.change_type.sms">
<el-row :gutter="36">
<el-col :span="18">
<el-input v-model="form.mobile" ref="phone" clearable
@ -123,7 +123,7 @@
</el-row>
</el-form-item>
<el-form-item label="手机验证码">
<el-form-item label="手机验证码" v-if="cptch.change_type.sms">
<el-row :gutter="11">
<el-col :span="12">
<el-input v-model="form.auth_key" prefix-icon="el-icon-mobile" placeholder="请输入您收到的验证码"
@ -226,16 +226,8 @@
name: "FirUserProfileCertification",
data() {
return {
form: {
name: '',
card: '',
addr: '',
mobile: '',
authcode: '',
cptch_key: '',
auth_token: '',
},
cptch: {"cptch_image": '', "cptch_key": '', "length": 8},
form: {},
cptch: {cptch_image: '', cptch_key: '',authcode:'', length: 8, change_type:{email:false,sms:false}},
user_certification: {'one': '', 'two': '', 'three': ''},
certification: {},
certification_status: 0,
@ -264,12 +256,13 @@
this.$message.error("身份证输入不合法");
return false;
}
if(this.cptch.change_type.sms){
let checkp = checkphone(this.form.mobile);
if (!checkp) {
this.$message.error("手机号输入不合法");
return false;
}
}
this.get_user_certification({methods: 'POST', data: this.form})
},
get_user_certification(params) {
@ -352,11 +345,15 @@
},
get_auth_code() {
if(this.form.authcode){
this.form.authcode = '';
}
changeInfoFun(data => {
if (data.code === 1000) {
this.cptch = data.data;
if(this.cptch.cptch_key){
this.form.cptch_key = this.cptch.cptch_key;
}
} else {
this.$message({
message: data.msg,
@ -390,7 +387,7 @@
},
init() {
if (this.$store.state.userinfo.certification) {
if (this.$store.state.userinfo.certification||this.$store.state.userinfo.certification===0) {
this.certification_status = this.$store.state.userinfo.certification;
if (this.certification_status !== -1) {
this.get_user_certification({methods: 'GET', data: {act: 'usercert'}});

@ -29,13 +29,13 @@
<el-row :gutter="36">
<el-col :span="16">
<el-input v-model="userinfo.mobile" ref="phone" :readonly="editphone !== true"
prefix-icon="el-icon-mobile" placeholder="手机" maxlength="11" clearable/>
prefix-icon="el-icon-mobile" placeholder="手机" maxlength="11" clearable :disabled="!cptch.change_type.sms"/>
</el-col>
<el-col :span="1">
<el-button icon="el-icon-edit" @click="changePhoneValue">
</el-button>
</el-col>
<el-col :span="5" v-if="editphone === true">
<el-col :span="5" v-if="editphone === true && cptch.change_type.sms">
<el-button type="success" @click="savePhone" plain
class="save-button">
保存
@ -44,7 +44,7 @@
</el-row>
</el-form-item>
<el-form-item label="图片验证码" style="height: 40px" v-if="editphone === true && cptch.cptch_image">
<el-form-item label="图片验证码" style="height: 40px" v-if="editphone === true && cptch.cptch_image && cptch.change_type.sms">
<el-row style="height: 40px" :gutter="36">
<el-col :span="14">
<el-input placeholder="请输入图片验证码" v-model="userinfo.authcode" maxlength="6" clearable/>
@ -59,7 +59,7 @@
</el-row>
</el-form-item>
<el-form-item label="手机验证码" v-if="editphone === true">
<el-form-item label="手机验证码" v-if="editphone === true && cptch.change_type.sms">
<el-row :gutter="36">
<el-col :span="16">
<el-input v-model="userinfo.auth_key" prefix-icon="el-icon-mobile" placeholder="验证码"
@ -80,13 +80,13 @@
<el-row :gutter="36">
<el-col :span="16">
<el-input v-model="userinfo.email" ref="email" :readonly="editemail !== true"
prefix-icon="el-icon-bank-card" placeholder="邮箱" maxlength="20" clearable/>
prefix-icon="el-icon-bank-card" placeholder="邮箱" maxlength="20" clearable :disabled="!cptch.change_type.email"/>
</el-col>
<el-col :span="1">
<el-button icon="el-icon-edit" @click="changeemailValue">
</el-button>
</el-col>
<el-col :span="5" v-if="editemail === true">
<el-col :span="5" v-if="editemail === true && cptch.change_type.email">
<el-button type="success" @click="saveemail" plain
class="save-button">
保存
@ -96,7 +96,7 @@
</el-form-item>
<el-form-item label="图片验证码" style="height: 40px" v-if="editemail === true && cptch.cptch_image">
<el-form-item label="图片验证码" style="height: 40px" v-if="editemail === true && cptch.cptch_image && cptch.change_type.email">
<el-row style="height: 40px" :gutter="36">
<el-col :span="14">
<el-input placeholder="请输入图片验证码" v-model="userinfo.authcode" maxlength="6" clearable/>
@ -111,7 +111,7 @@
</el-row>
</el-form-item>
<el-form-item label="邮箱验证码" v-if="editemail === true">
<el-form-item label="邮箱验证码" v-if="editemail === true && cptch.change_type.email">
<el-row :gutter="36">
<el-col :span="16">
<el-input v-model="userinfo.auth_key" prefix-icon="el-icon-mobile" placeholder="验证码"
@ -199,7 +199,7 @@
editdomain_name: false,
edituser_name: false,
editposition: false,
cptch: {"cptch_image": '', "cptch_key": '', "length": 8},
cptch: {"cptch_image": '', "cptch_key": '', "length": 8, change_type:{email:false,sms:false}},
form: {},
}
}, methods: {

@ -0,0 +1,23 @@
# Generated by Django 3.0.3 on 2021-04-23 16:45
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('api', '0044_auto_20210422_1002'),
]
operations = [
migrations.AlterField(
model_name='usercertificationinfo',
name='card',
field=models.CharField(max_length=128, unique=True, verbose_name='身份证号码'),
),
migrations.AlterField(
model_name='usercertificationinfo',
name='mobile',
field=models.BigIntegerField(blank=True, null=True, verbose_name='手机号码'),
),
]

@ -0,0 +1,18 @@
# Generated by Django 3.0.3 on 2021-04-23 16:50
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('api', '0045_auto_20210423_1645'),
]
operations = [
migrations.AlterField(
model_name='usercertificationinfo',
name='reviewed_time',
field=models.DateTimeField(auto_now_add=True, verbose_name='审核时间'),
),
]

@ -414,14 +414,14 @@ class UserCertificationInfo(models.Model):
user_id = models.OneToOneField(to="UserInfo", verbose_name="用户ID", on_delete=models.CASCADE,
related_name='certification')
name = models.CharField(max_length=128, null=False, verbose_name="真实姓名")
card = models.CharField(max_length=128, null=False, verbose_name="身份证号码")
card = models.CharField(max_length=128, null=False, verbose_name="身份证号码", unique=True)
addr = models.CharField(max_length=128, null=False, verbose_name="居住地址")
mobile = models.BigIntegerField(verbose_name="手机号码", unique=True, null=False)
mobile = models.BigIntegerField(verbose_name="手机号码", null=True, blank=True)
status_choices = ((-1, '待认证'), (0, '认证中'), (1, '认证成功'), (2, '认证失败'))
status = models.SmallIntegerField(choices=status_choices, default=0, verbose_name="认证状态")
msg = models.CharField(max_length=512, null=True, blank=True, verbose_name="备注")
created_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
reviewed_time = models.DateTimeField(auto_now_add=False, verbose_name="审核时间")
reviewed_time = models.DateTimeField(auto_now_add=True, verbose_name="审核时间")
class Meta:
verbose_name = '用户认证信息'

@ -630,24 +630,22 @@ class CertificationView(APIView):
return Response(res.dict)
try:
if REGISTER.get("captcha"):
if CHANGER.get("captcha"):
if data and valid_captcha(data.get("cptch_key", None), data.get("authcode", None), data.get("mobile")):
pass
del data["cptch_key"]
del data["authcode"]
else:
res.code = 1009
res.msg = "图片验证码有误"
return Response(res.dict)
if CHANGER.get('change_type').get('sms'):
is_valid, target = is_valid_sender_code('sms', data.get("auth_token", None), data.get("auth_key", None))
if is_valid and str(target) == str(data.get("mobile")):
if login_auth_failed("get", data.get("mobile")):
del data["cptch_key"]
del data["authcode"]
del data["auth_key"]
del data["auth_token"]
UserCertificationInfo.objects.update_or_create(user_id=request.user, status=0, defaults=data)
return self.get(request)
else:
res.code = 1006
logger.error("username:%s failed too try , locked" % (request.user,))
@ -655,7 +653,9 @@ class CertificationView(APIView):
else:
res.code = 1001
res.msg = "短信验证码有误"
else:
UserCertificationInfo.objects.update_or_create(user_id=request.user, status=0, defaults=data)
return self.get(request)
except Exception as e:
logger.error("%s UserCertificationInfo save %s failed Exception: %s" % (request.user, data, e))
res.msg = "数据异常,请检查"
@ -664,8 +664,7 @@ class CertificationView(APIView):
class ChangeInfoView(APIView):
throttle_classes = [VisitRegister1Throttle, VisitRegister2Throttle]
authentication_classes = [ExpiringTokenAuthentication, ]
def get(self, request):
response = BaseResponse()
response.data = {}

@ -191,7 +191,7 @@ GEETEST_BYPASS_URL = "http://bypass.geetest.com/v1/bypass_status.php"
# 注册方式,如果启用sms或者email 需要配置 THIRD_PART_CONFIG.sender 信息
REGISTER = {
"enable": True,
"captcha": True, # 是否开启注册字母验证码
"captcha": False, # 是否开启注册字母验证码
"geetest": True, # 是否开启geetest验证,如要开启请先配置geetest
"register_type": {
'sms': False, # 短信注册
@ -202,7 +202,7 @@ REGISTER = {
# 个人资料修改修改也会使用该配置
CHANGER = {
"enable": True,
"captcha": True, # 是否开启注册字母验证码
"captcha": False, # 是否开启注册字母验证码
"geetest": True, # 是否开启geetest验证,如要开启请先配置geetest
"change_type": {
'sms': False, # 短信注册
@ -211,10 +211,10 @@ CHANGER = {
}
}
LOGIN = {
"captcha": True, # 是否开启登录字母验证码
"captcha": False, # 是否开启登录字母验证码
"geetest": True, # 是否开启geetest验证
"login_type": {
'sms': True, # 短信登录
'sms': False, # 短信登录
'email': True, # 邮件登录
'up': True, # 密码登录
}

Loading…
Cancel
Save