实名认证显示优化

pull/16/head
nineven 4 years ago
parent cfc31fc9d8
commit cdf43a7f41
  1. 55
      fir_client/src/components/user/FirUserProfileCertification.vue
  2. 18
      fir_ser/api/utils/serializer.py
  3. 14
      fir_ser/api/views/login.py
  4. 6
      fir_ser/fir_ser/settings.py

@ -1,5 +1,5 @@
<template>
<div v-if="certification && certification.code === 0">
<div v-if="certification && !cert_edit_flag">
<el-form style="max-width: 400px">
<el-form-item>
<el-row>
@ -55,7 +55,6 @@
</el-col>
</el-row>
</el-form-item>
<el-form-item v-if="certification.status === 2">
<el-row>
<el-col :span="24">
@ -63,7 +62,13 @@
</el-col>
</el-row>
</el-form-item>
<el-form-item v-if="certification_status === -1">
<el-row>
<el-col :span="24">
<el-button type="primary" @click="goauth">开始认证</el-button>
</el-col>
</el-row>
</el-form-item>
</el-form>
</div>
<div v-else>
@ -227,24 +232,31 @@
name: '',
card: '',
addr: '',
mobile: '15738962953',
mobile: '',
authcode: '',
cptch_key: '',
auth_token: '',
},
cptch: {"cptch_image": '', "cptch_key": '', "length": 8},
user_certification: {'one': '', 'two': '', 'three': ''},
certification: {'code': 0},
certification: {},
certification_status: 0,
cert_edit_flag: false
}
}, methods: {
goauth() {
this.cert_edit_flag = true;
this.get_user_certification({methods: 'GET', data: {act: 'certpiccertinfo'}});
this.get_auth_code();
},
recommit() {
this.certification.code = -1;
this.cert_edit_flag = true;
this.get_user_certification({methods: 'GET', data: {act: 'certpiccertinfo'}});
this.get_auth_code();
},
commit() {
for (let v of Object.keys(this.form)) {
if (this.form[v].length < 4) {
if (this.form[v].length < 2) {
this.$message.error("填写错误,请检查");
return false
}
@ -268,15 +280,20 @@
if (params.methods === 'POST') {
this.$message.success("信息提交成功,正在审核中")
}
const ft = ['one', 'two', 'three'];
if (res.data.certification && res.data.certification.length > 0) {
for (let v of res.data.certification) {
this.user_certification[ft[v.type - 1]] = v.certification_url;
if (res.data.usercert) {
this.certification = res.data.usercert;
} else {
const ft = ['one', 'two', 'three'];
if (res.data.certification && res.data.certification.length > 0) {
for (let v of res.data.certification) {
this.user_certification[ft[v.type - 1]] = v.certification_url;
}
}
if (res.data.user_certification) {
this.form = res.data.user_certification;
}
}
if (res.data.user_certification) {
this.form = res.data.user_certification;
}
} else {
this.$message.error(res.msg)
}
@ -375,12 +392,12 @@
},
init() {
if (this.$store.state.userinfo.certification) {
this.certification = this.$store.state.userinfo.certification;
}
if (this.certification.code === -1) {
this.get_user_certification({methods: 'GET', data: {act: 'certpiccertinfo'}});
this.get_auth_code();
this.certification_status = this.$store.state.userinfo.certification;
if (this.certification_status !== -1) {
this.get_user_certification({methods: 'GET', data: {act: 'usercert'}});
}
}
},
}, mounted() {
this.$store.dispatch('douserInfoIndex', 2);

@ -46,7 +46,7 @@ class UserInfoSerializer(serializers.ModelSerializer):
# fields="__all__"
fields = ["username", "uid", "mobile", "job", "email", "domain_name", "role", "first_name",
'head_img', 'storage_active', 'supersign_active', 'free_download_times', 'download_times',
'certification']
'certification', 'is_active', "date_joined"]
head_img = serializers.SerializerMethodField()
@ -62,21 +62,11 @@ class UserInfoSerializer(serializers.ModelSerializer):
certification = serializers.SerializerMethodField()
def get_certification(self, obj):
result = {'code': -1}
auth_status = -1
certification_obj = models.UserCertificationInfo.objects.filter(user_id=obj).first()
if certification_obj:
result['code'] = 0
card = certification_obj.card
data = {
'name': certification_obj.name,
'addr': certification_obj.addr,
'card': "%s%s%s" % (card[:4], '*' * (len(card) - 8), card[-4:]),
'mobile': certification_obj.mobile,
'status': certification_obj.status,
'msg': certification_obj.msg,
}
result.update(data)
return result
auth_status = certification_obj.status
return auth_status
class AppsSerializer(serializers.ModelSerializer):

@ -581,6 +581,9 @@ class UserApiTokenView(APIView):
request.user.save()
except Exception as e:
logger.error("User %s api_token save failed. Excepiton:%s" % (request.user, e))
res.code = 1002
res.msg = "token 生成失败"
return Response(res.dict)
return self.get(request)
@ -592,7 +595,16 @@ class CertificationView(APIView):
res.data = {}
act = request.query_params.get("act", "")
user_certification_obj = UserCertificationInfo.objects.filter(user_id=request.user).first()
if user_certification_obj and user_certification_obj.status == 1:
if user_certification_obj and user_certification_obj.status == 1 or act == "usercert":
card = user_certification_obj.card
res.data["usercert"] = {
'name': user_certification_obj.name,
'addr': user_certification_obj.addr,
'card': "%s%s%s" % (card[:4], '*' * (len(card) - 8), card[-4:]),
'mobile': user_certification_obj.mobile,
'status': user_certification_obj.status,
'msg': user_certification_obj.msg,
}
return Response(res.dict)
if 'certinfo' in act:

@ -24,7 +24,7 @@ SECRET_KEY = 'j!g@^bc(z(a3*i&kp$_@bgb)bug&^#3=amch!3lz&1x&s6ss6t'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ['127.0.0.1', 'synchrotron']
ALLOWED_HOSTS = ['127.0.0.1', 'synchrotron', '172.16.133.34']
# Application definition
@ -190,7 +190,7 @@ GEETEST_BYPASS_URL = "http://bypass.geetest.com/v1/bypass_status.php"
# 注册方式,如果启用sms或者email 需要配置 THIRD_PART_CONFIG.sender 信息
REGISTER = {
"enable": True,
"enable": False,
"captcha": False, # 是否开启注册字母验证码
"geetest": True, # 是否开启geetest验证,如要开启请先配置geetest
"register_type": {
@ -203,7 +203,7 @@ REGISTER = {
# 信息修改也会使用该配置
LOGIN = {
"captcha": False, # 是否开启登录字母验证码
"geetest": True, # 是否开启geetest验证
"geetest": False, # 是否开启geetest验证
"login_type": {
'sms': True, # 短信登录
'email': True, # 邮件登录

Loading…
Cancel
Save