增加个人信息修改验证

v1.0.0
youngS 4 years ago
parent 35e6ac8e39
commit 056b30bc82
  1. 9
      fir_client/src/components/FirLogin.vue
  2. 15
      fir_client/src/components/FirRegist.vue
  3. 36
      fir_client/src/components/user/FirUserProfileCertification.vue
  4. 49
      fir_client/src/components/user/FirUserProfileInfo.vue
  5. 15
      fir_client/src/restful/index.js
  6. 3
      fir_ser/api/urls.py
  7. 2
      fir_ser/api/utils/utils.py
  8. 19
      fir_ser/api/views/login.py
  9. 19
      fir_ser/fir_ser/settings.py

@ -35,17 +35,17 @@
<el-form-item v-if="is_cptch">
<el-input v-model="form.password" prefix-icon="el-icon-lock" placeholder="密码"
@keyup.enter.native="onSubmit"
show-password/>
show-password clearable/>
</el-form-item>
<el-form-item v-else>
<el-input v-model="form.password" prefix-icon="el-icon-lock" placeholder="密码"
show-password/>
show-password clearable/>
</el-form-item>
<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"/>
@keyup.enter.native="onSubmit" clearable/>
</el-col>
<el-col :span="8">
<el-image
@ -150,8 +150,6 @@
});
return
}
if (password.length > 6) {
let params = {
"username": email,
@ -235,6 +233,7 @@
this.cptch = data.data;
this.allow_ways = data.data.login_type;
this.register_enable = data.data.register_enable;
this.form.authcode = '';
this.set_rtitle();
this.set_activename();
} else {

@ -29,7 +29,7 @@
<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 placeholder="请输入图片验证码" v-model="form.authcode" maxlength="6" clearable/>
</el-col>
<el-col :span="8">
<el-image
@ -46,7 +46,7 @@
<el-row>
<el-col :span="16">
<el-input v-model="form.seicode" prefix-icon="el-icon-mobile"
placeholder="验证码"/>
placeholder="验证码" clearable/>
</el-col>
<el-col :span="8">
<el-button type="info" @click="getphonecode" plain
@ -59,11 +59,11 @@
<el-form-item>
<el-input v-model="form.password" prefix-icon="el-icon-lock" placeholder="密码"
show-password/>
show-password clearable/>
</el-form-item>
<el-form-item>
<el-input v-model="form.password2" prefix-icon="el-icon-lock" placeholder="确认密码"
show-password @keyup.enter.native="onRegist"/>
show-password @keyup.enter.native="onRegist" clearable/>
</el-form-item>
<el-form-item>
@ -132,6 +132,7 @@
if (jdata.enable) {
this.allow_r = true;
this.allow_ways = jdata.register_type;
this.form.authcode = '';
this.set_rtitle();
this.cptch = data.data;
} else {
@ -318,12 +319,6 @@
onLogin() {
this.$router.push({name: 'FirLogin'})
},
// isEmail(input) {
// if (input.match(/^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/)) {
// return true;
// }
// return false;
// }
}
,
created() {

@ -108,7 +108,20 @@
</el-col>
</el-row>
</el-form-item>
<el-form-item label="图片验证码" v-if="cptch.cptch_image">
<el-row :gutter="11">
<el-col :span="12">
<el-input placeholder="请输入图片验证码" v-model="form.authcode" maxlength="6" clearable/>
</el-col>
<el-col :span="6">
<el-image
style="border-radius:4px;cursor:pointer;height: 40px"
:src="cptch.cptch_image"
fit="contain" @click="get_auth_code">
</el-image>
</el-col>
</el-row>
</el-form-item>
<el-form-item label="手机验证码">
<el-row :gutter="11">
@ -126,23 +139,9 @@
</el-row>
</el-form-item>
<el-form-item label="图片验证码" v-if="cptch.cptch_image">
<el-row :gutter="11">
<el-col :span="12">
<el-input placeholder="请输入图片验证码" v-model="form.authcode" maxlength="6" clearable/>
</el-col>
<el-col :span="6">
<el-image
style="border-radius:4px;cursor:pointer;height: 40px"
:src="cptch.cptch_image"
fit="contain" @click="get_auth_code">
</el-image>
</el-col>
</el-row>
</el-form-item>
<el-form-item>
<el-row style="margin-left: 88px">
<el-col :span="8">
<el-col :span="13">
<div id="captcha" ref="captcha"></div>
</el-col>
</el-row>
@ -220,7 +219,7 @@
</template>
<script>
import {getAuthcTokenFun, registerFun, user_certification} from "@/restful";
import {changeInfoFun, getAuthcTokenFun, user_certification} from "@/restful";
import {AvatarUploadUtils, checkphone, geetest} from "@/utils";
export default {
@ -353,7 +352,8 @@
},
get_auth_code() {
registerFun(data => {
this.form.authcode = '';
changeInfoFun(data => {
if (data.code === 1000) {
this.cptch = data.data;
this.form.cptch_key = this.cptch.cptch_key;

@ -126,7 +126,13 @@
</el-row>
</el-form-item>
<el-form-item v-if="editphone === true || editemail === true">
<el-row :gutter="36">
<el-col :span="18">
<div id="captcha" ref="captcha"></div>
</el-col>
</el-row>
</el-form-item>
<el-form-item label="下载域名">
<el-row :gutter="36">
@ -176,8 +182,8 @@
</template>
<script>
import {getAuthcTokenFun, registerFun, userinfos} from '@/restful'
import {deepCopy} from "@/utils";
import {changeInfoFun, getAuthcTokenFun, userinfos} from '@/restful'
import {deepCopy, geetest} from "@/utils";
export default {
name: "FirUserProfileInfo",
@ -185,6 +191,7 @@
return {
userinfo: {
srccode: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg',
authcode: ''
},
orguserinfo: {},
editphone: false,
@ -193,13 +200,17 @@
edituser_name: false,
editposition: false,
cptch: {"cptch_image": '', "cptch_key": '', "length": 8},
form: {},
}
}, methods: {
get_auth_code() {
registerFun(data => {
changeInfoFun(data => {
if (data.code === 1000) {
this.cptch = data.data;
this.userinfo.cptch_key = this.cptch.cptch_key;
if (this.userinfo.authcode) {
this.userinfo.authcode = '';
}
} else {
this.$message({
message: data.msg,
@ -316,17 +327,12 @@
} else {
this.$refs.domain_name.$el.children[0].style.backgroundColor = '#f6ffdc';
}
},
getsmsemailcode(act, target) {
let picode = {
"authcode": this.userinfo.authcode,
"cptch_key": this.cptch.cptch_key,
};
}, do_get_auth_token(params) {
getAuthcTokenFun(data => {
if (data.code === 1000) {
this.userinfo.act = act;
this.userinfo.act = params.act;
let msg = '您正在修改手机号码,验证码已经发送您手机';
if (act === "email") {
if (params.act === "email") {
msg = '您正在修改邮箱,验证码已经发送您邮箱';
}
this.$notify({
@ -339,7 +345,24 @@
this.$message.error(data.msg)
}
}, {"methods": 'POST', 'data': {'act': act, 'target': target, 'ext': picode}})
}, {"methods": 'POST', 'data': params})
},
getsmsemailcode(act, target) {
let picode = {
"authcode": this.userinfo.authcode,
"cptch_key": this.cptch.cptch_key,
};
let params = {
'act': act, 'target': target, 'ext': picode
};
if (this.cptch.geetest) {
this.form.email = target;
geetest(this, params, (n_params) => {
this.do_get_auth_token(n_params);
})
} else {
this.do_get_auth_token(params);
}
}
}, mounted() {
this.$store.dispatch('douserInfoIndex', 0);

@ -528,3 +528,18 @@ export function user_certification(callBack, params, load = true) {
true
);
}
/**用户信息修改验证 */
export function changeInfoFun(callBack, params, load = true) {
getData(
params.methods,
USERSEVER + '/change',
params.data,
data => {
callBack(data);
},
load,
true,
true
);
}

@ -16,7 +16,7 @@ Including another URLconf
from django.urls import path, re_path, include
from api.views.login import LoginView, UserInfoView, RegistView, AuthorizationView, ChangeAuthorizationView, \
UserApiTokenView, CertificationView
UserApiTokenView, CertificationView, ChangeInfoView
from api.views.logout import LogoutView
from api.views.apps import AppsView, AppInfoView, AppReleaseinfoView
from api.views.download import ShortDownloadView
@ -34,6 +34,7 @@ urlpatterns = [
re_path("^login", LoginView.as_view()),
re_path("^auth$", AuthorizationView.as_view()),
re_path("^authc$", ChangeAuthorizationView.as_view()),
re_path("^change$", ChangeInfoView.as_view()),
re_path("^register", RegistView.as_view()),
re_path("^logout", LogoutView.as_view()),
re_path("^apps$", AppsView.as_view()),

@ -70,7 +70,7 @@ def get_captcha():
cptch_image = captcha_image_url(cptch_key)
CaptchaStore.remove_expired()
local_storage = LocalStorage(**SERVER_DOMAIN.get("IOS_PMFILE_DOWNLOAD_DOMAIN"))
return {"cptch_image": "/".join([local_storage.get_base_url(), cptch_image.strip("/")]), "cptch_key": cptch_key,
return {"cptch_image": "/".join([local_storage.get_base_url(), cptch_image.strip("/"), '']), "cptch_key": cptch_key,
"length": CAPTCHA_LENGTH}

@ -12,7 +12,7 @@ from api.utils.utils import get_captcha, valid_captcha, \
from api.utils.baseutils import is_valid_domain, is_valid_phone, is_valid_email
from api.utils.auth import ExpiringTokenAuthentication
from api.utils.response import BaseResponse
from fir_ser.settings import CACHE_KEY_TEMPLATE, SERVER_DOMAIN, REGISTER, LOGIN
from fir_ser.settings import CACHE_KEY_TEMPLATE, SERVER_DOMAIN, REGISTER, LOGIN, CHANGER
from api.utils.storage.caches import login_auth_failed, set_default_app_wx_easy
import logging
from api.utils.geetest.geetest_utils import first_register, second_validate
@ -661,3 +661,20 @@ class CertificationView(APIView):
res.msg = "数据异常,请检查"
res.code = 1002
return Response(res.dict)
class ChangeInfoView(APIView):
throttle_classes = [VisitRegister1Throttle, VisitRegister2Throttle]
def get(self, request):
response = BaseResponse()
response.data = {}
allow_f = CHANGER.get("enable")
if allow_f:
if CHANGER.get("captcha"):
response.data = get_captcha()
if CHANGER.get("geetest"):
response.data['geetest'] = True
response.data['change_type'] = CHANGER.get("change_type")
response.data['enable'] = allow_f
return Response(response.dict)

@ -189,10 +189,9 @@ GEETEST_BYPASS_STATUS_KEY = "gt_server_bypass_status"
GEETEST_BYPASS_URL = "http://bypass.geetest.com/v1/bypass_status.php"
# 注册方式,如果启用sms或者email 需要配置 THIRD_PART_CONFIG.sender 信息
# 个人资料修改修改也会使用该配置
REGISTER = {
"enable": True,
"captcha": False, # 是否开启注册字母验证码
"captcha": True, # 是否开启注册字母验证码
"geetest": True, # 是否开启geetest验证,如要开启请先配置geetest
"register_type": {
'sms': False, # 短信注册
@ -200,10 +199,20 @@ REGISTER = {
'code': False, # 邀请码注册,邀请码必填写,需要和短信,邮件一起使用
}
}
# 个人资料修改修改也会使用该配置
CHANGER = {
"enable": True,
"captcha": True, # 是否开启注册字母验证码
"geetest": True, # 是否开启geetest验证,如要开启请先配置geetest
"change_type": {
'sms': False, # 短信注册
'email': True, # 邮件注册
'code': False, # 邀请码注册,邀请码必填写,需要和短信,邮件一起使用
}
}
LOGIN = {
"captcha": False, # 是否开启登录字母验证码
"geetest": False, # 是否开启geetest验证
"captcha": True, # 是否开启登录字母验证码
"geetest": True, # 是否开启geetest验证
"login_type": {
'sms': True, # 短信登录
'email': True, # 邮件登录

Loading…
Cancel
Save