实名认证显示优化

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

@ -46,7 +46,7 @@ class UserInfoSerializer(serializers.ModelSerializer):
# fields="__all__" # fields="__all__"
fields = ["username", "uid", "mobile", "job", "email", "domain_name", "role", "first_name", fields = ["username", "uid", "mobile", "job", "email", "domain_name", "role", "first_name",
'head_img', 'storage_active', 'supersign_active', 'free_download_times', 'download_times', 'head_img', 'storage_active', 'supersign_active', 'free_download_times', 'download_times',
'certification'] 'certification', 'is_active', "date_joined"]
head_img = serializers.SerializerMethodField() head_img = serializers.SerializerMethodField()
@ -62,21 +62,11 @@ class UserInfoSerializer(serializers.ModelSerializer):
certification = serializers.SerializerMethodField() certification = serializers.SerializerMethodField()
def get_certification(self, obj): def get_certification(self, obj):
result = {'code': -1} auth_status = -1
certification_obj = models.UserCertificationInfo.objects.filter(user_id=obj).first() certification_obj = models.UserCertificationInfo.objects.filter(user_id=obj).first()
if certification_obj: if certification_obj:
result['code'] = 0 auth_status = certification_obj.status
card = certification_obj.card return auth_status
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
class AppsSerializer(serializers.ModelSerializer): class AppsSerializer(serializers.ModelSerializer):

@ -581,6 +581,9 @@ class UserApiTokenView(APIView):
request.user.save() request.user.save()
except Exception as e: except Exception as e:
logger.error("User %s api_token save failed. Excepiton:%s" % (request.user, 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) return self.get(request)
@ -592,7 +595,16 @@ class CertificationView(APIView):
res.data = {} res.data = {}
act = request.query_params.get("act", "") act = request.query_params.get("act", "")
user_certification_obj = UserCertificationInfo.objects.filter(user_id=request.user).first() 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) return Response(res.dict)
if 'certinfo' in act: 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! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True DEBUG = True
ALLOWED_HOSTS = ['127.0.0.1', 'synchrotron'] ALLOWED_HOSTS = ['127.0.0.1', 'synchrotron', '172.16.133.34']
# Application definition # Application definition
@ -190,7 +190,7 @@ GEETEST_BYPASS_URL = "http://bypass.geetest.com/v1/bypass_status.php"
# 注册方式,如果启用sms或者email 需要配置 THIRD_PART_CONFIG.sender 信息 # 注册方式,如果启用sms或者email 需要配置 THIRD_PART_CONFIG.sender 信息
REGISTER = { REGISTER = {
"enable": True, "enable": False,
"captcha": False, # 是否开启注册字母验证码 "captcha": False, # 是否开启注册字母验证码
"geetest": True, # 是否开启geetest验证,如要开启请先配置geetest "geetest": True, # 是否开启geetest验证,如要开启请先配置geetest
"register_type": { "register_type": {
@ -203,7 +203,7 @@ REGISTER = {
# 信息修改也会使用该配置 # 信息修改也会使用该配置
LOGIN = { LOGIN = {
"captcha": False, # 是否开启登录字母验证码 "captcha": False, # 是否开启登录字母验证码
"geetest": True, # 是否开启geetest验证 "geetest": False, # 是否开启geetest验证
"login_type": { "login_type": {
'sms': True, # 短信登录 'sms': True, # 短信登录
'email': True, # 邮件登录 'email': True, # 邮件登录

Loading…
Cancel
Save