增加个人信息修改验证

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

@ -29,7 +29,7 @@
<el-form-item style="height: 40px" v-if="cptch.cptch_image"> <el-form-item style="height: 40px" v-if="cptch.cptch_image">
<el-row style="height: 40px"> <el-row style="height: 40px">
<el-col :span="16"> <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>
<el-col :span="8"> <el-col :span="8">
<el-image <el-image
@ -46,7 +46,7 @@
<el-row> <el-row>
<el-col :span="16"> <el-col :span="16">
<el-input v-model="form.seicode" prefix-icon="el-icon-mobile" <el-input v-model="form.seicode" prefix-icon="el-icon-mobile"
placeholder="验证码"/> placeholder="验证码" clearable/>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<el-button type="info" @click="getphonecode" plain <el-button type="info" @click="getphonecode" plain
@ -59,11 +59,11 @@
<el-form-item> <el-form-item>
<el-input v-model="form.password" prefix-icon="el-icon-lock" placeholder="密码" <el-input v-model="form.password" prefix-icon="el-icon-lock" placeholder="密码"
show-password/> show-password clearable/>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-input v-model="form.password2" prefix-icon="el-icon-lock" placeholder="确认密码" <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>
<el-form-item> <el-form-item>
@ -132,6 +132,7 @@
if (jdata.enable) { if (jdata.enable) {
this.allow_r = true; this.allow_r = true;
this.allow_ways = jdata.register_type; this.allow_ways = jdata.register_type;
this.form.authcode = '';
this.set_rtitle(); this.set_rtitle();
this.cptch = data.data; this.cptch = data.data;
} else { } else {
@ -318,12 +319,6 @@
onLogin() { onLogin() {
this.$router.push({name: 'FirLogin'}) 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() { created() {

@ -108,7 +108,20 @@
</el-col> </el-col>
</el-row> </el-row>
</el-form-item> </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-form-item label="手机验证码">
<el-row :gutter="11"> <el-row :gutter="11">
@ -126,23 +139,9 @@
</el-row> </el-row>
</el-form-item> </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-form-item>
<el-row style="margin-left: 88px"> <el-row style="margin-left: 88px">
<el-col :span="8"> <el-col :span="13">
<div id="captcha" ref="captcha"></div> <div id="captcha" ref="captcha"></div>
</el-col> </el-col>
</el-row> </el-row>
@ -220,7 +219,7 @@
</template> </template>
<script> <script>
import {getAuthcTokenFun, registerFun, user_certification} from "@/restful"; import {changeInfoFun, getAuthcTokenFun, user_certification} from "@/restful";
import {AvatarUploadUtils, checkphone, geetest} from "@/utils"; import {AvatarUploadUtils, checkphone, geetest} from "@/utils";
export default { export default {
@ -353,7 +352,8 @@
}, },
get_auth_code() { get_auth_code() {
registerFun(data => { this.form.authcode = '';
changeInfoFun(data => {
if (data.code === 1000) { if (data.code === 1000) {
this.cptch = data.data; this.cptch = data.data;
this.form.cptch_key = this.cptch.cptch_key; this.form.cptch_key = this.cptch.cptch_key;

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

@ -527,4 +527,19 @@ export function user_certification(callBack, params, load = true) {
true, true,
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 django.urls import path, re_path, include
from api.views.login import LoginView, UserInfoView, RegistView, AuthorizationView, ChangeAuthorizationView, \ from api.views.login import LoginView, UserInfoView, RegistView, AuthorizationView, ChangeAuthorizationView, \
UserApiTokenView, CertificationView UserApiTokenView, CertificationView, ChangeInfoView
from api.views.logout import LogoutView from api.views.logout import LogoutView
from api.views.apps import AppsView, AppInfoView, AppReleaseinfoView from api.views.apps import AppsView, AppInfoView, AppReleaseinfoView
from api.views.download import ShortDownloadView from api.views.download import ShortDownloadView
@ -34,6 +34,7 @@ urlpatterns = [
re_path("^login", LoginView.as_view()), re_path("^login", LoginView.as_view()),
re_path("^auth$", AuthorizationView.as_view()), re_path("^auth$", AuthorizationView.as_view()),
re_path("^authc$", ChangeAuthorizationView.as_view()), re_path("^authc$", ChangeAuthorizationView.as_view()),
re_path("^change$", ChangeInfoView.as_view()),
re_path("^register", RegistView.as_view()), re_path("^register", RegistView.as_view()),
re_path("^logout", LogoutView.as_view()), re_path("^logout", LogoutView.as_view()),
re_path("^apps$", AppsView.as_view()), re_path("^apps$", AppsView.as_view()),

@ -70,7 +70,7 @@ def get_captcha():
cptch_image = captcha_image_url(cptch_key) cptch_image = captcha_image_url(cptch_key)
CaptchaStore.remove_expired() CaptchaStore.remove_expired()
local_storage = LocalStorage(**SERVER_DOMAIN.get("IOS_PMFILE_DOWNLOAD_DOMAIN")) 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} "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.baseutils import is_valid_domain, is_valid_phone, is_valid_email
from api.utils.auth import ExpiringTokenAuthentication from api.utils.auth import ExpiringTokenAuthentication
from api.utils.response import BaseResponse 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 from api.utils.storage.caches import login_auth_failed, set_default_app_wx_easy
import logging import logging
from api.utils.geetest.geetest_utils import first_register, second_validate from api.utils.geetest.geetest_utils import first_register, second_validate
@ -661,3 +661,20 @@ class CertificationView(APIView):
res.msg = "数据异常,请检查" res.msg = "数据异常,请检查"
res.code = 1002 res.code = 1002
return Response(res.dict) 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" 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": True,
"captcha": False, # 是否开启注册字母验证码 "captcha": True, # 是否开启注册字母验证码
"geetest": True, # 是否开启geetest验证,如要开启请先配置geetest "geetest": True, # 是否开启geetest验证,如要开启请先配置geetest
"register_type": { "register_type": {
'sms': False, # 短信注册 'sms': False, # 短信注册
@ -200,10 +199,20 @@ REGISTER = {
'code': False, # 邀请码注册,邀请码必填写,需要和短信,邮件一起使用 'code': False, # 邀请码注册,邀请码必填写,需要和短信,邮件一起使用
} }
} }
# 个人资料修改修改也会使用该配置
CHANGER = {
"enable": True,
"captcha": True, # 是否开启注册字母验证码
"geetest": True, # 是否开启geetest验证,如要开启请先配置geetest
"change_type": {
'sms': False, # 短信注册
'email': True, # 邮件注册
'code': False, # 邀请码注册,邀请码必填写,需要和短信,邮件一起使用
}
}
LOGIN = { LOGIN = {
"captcha": False, # 是否开启登录字母验证码 "captcha": True, # 是否开启登录字母验证码
"geetest": False, # 是否开启geetest验证 "geetest": True, # 是否开启geetest验证
"login_type": { "login_type": {
'sms': True, # 短信登录 'sms': True, # 短信登录
'email': True, # 邮件登录 'email': True, # 邮件登录

Loading…
Cancel
Save