增加邮箱和手机号登录

pull/1/head
xiaoyu 4 years ago
parent d5c8a09ce6
commit d805283ef2
  1. 56
      fir_client/src/components/FirUserProfileInfo.vue
  2. 4
      fir_ser/api/urls.py
  3. 6
      fir_ser/api/views/login.py

@ -44,6 +44,21 @@
</el-row> </el-row>
</el-form-item> </el-form-item>
<el-form-item style="height: 40px" v-if="editphone === true">
<el-row style="height: 40px" :gutter="10">
<el-col :span="11">
<el-input placeholder="请输入图片验证码" v-model="userinfo.authcode" maxlength="6"></el-input>
</el-col>
<el-col :span="8">
<el-image
style="margin:0px 4px;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 v-if="editphone === true"> <el-form-item v-if="editphone === true">
<el-row :gutter="10"> <el-row :gutter="10">
<el-col :span="12"> <el-col :span="12">
@ -185,7 +200,6 @@
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;
} else { } else {
this.$message({ this.$message({
message: data.msg, message: data.msg,
@ -197,31 +211,46 @@
"data": {} "data": {}
}); });
}, },
saveemail() {
this.updateUserInfo({"methods": 'PUT', 'data': this.userinfo});
this.changeemailValue()
},
saveUsername() { saveUsername() {
this.updateUserInfo({"methods": 'PUT', 'data': this.userinfo}); if (this.userinfo.username.toString().length < 6) {
this.$message.error("密码至少6位");
return
}
this.updateUserInfo({"methods": 'PUT', 'data': {username:this.userinfo.username}});
this.changeUsernameValue() this.changeUsernameValue()
}, },
saveDomain() { saveDomain() {
this.updateUserInfo({"methods": 'PUT', 'data': this.userinfo}); this.updateUserInfo({"methods": 'PUT', 'data': {domain_name:this.userinfo.domain_name}});
this.changeDomainValue() this.changeDomainValue()
}, },
savePositionValue() { savePositionValue() {
this.updateUserInfo({"methods": 'PUT', 'data': this.userinfo}); this.updateUserInfo({"methods": 'PUT', 'data': {job:this.userinfo.job}});
this.changePositionValue() this.changePositionValue()
}, },
authinfo(){
return {
auth_token:this.userinfo.auth_token,
auth_key:this.userinfo.auth_key,
cptch_key:this.userinfo.cptch_key,
authcode:this.userinfo.authcode,
};
},
saveemail() {
let data = this.authinfo();
data.email = this.userinfo.email;
this.updateUserInfo({"methods": 'PUT', 'data': data});
this.changeemailValue()
},
savePhone() { savePhone() {
this.updateUserInfo({"methods": 'PUT', 'data': this.userinfo}); let data = this.authinfo();
data.mobile = this.userinfo.mobile;
this.updateUserInfo({"methods": 'PUT', 'data': data});
this.changePhoneValue() this.changePhoneValue()
}, },
updateUserInfo(datainfo) { updateUserInfo(datainfo) {
if (datainfo.data.username.toString().length < 6) {
this.$message.error("密码至少6位");
return
}
userinfos(data => { userinfos(data => {
if (data.code === 1000) { if (data.code === 1000) {
@ -264,6 +293,7 @@
}, },
changePhoneValue() { changePhoneValue() {
this.get_auth_code();
this.editphone = !this.editphone; this.editphone = !this.editphone;
if (this.$refs.phone.$el.children[0].style.backgroundColor) { if (this.$refs.phone.$el.children[0].style.backgroundColor) {
this.$refs.phone.$el.children[0].style.backgroundColor = '' this.$refs.phone.$el.children[0].style.backgroundColor = ''

@ -32,8 +32,8 @@ from api.views.supersign import DeveloperView, SuperSignUsedView, AppUDIDUsedVie
urlpatterns = [ urlpatterns = [
# path("",include(router.urls)), # path("",include(router.urls)),
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("^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()),

@ -319,6 +319,9 @@ class UserInfoView(APIView):
oldpassword = data.get("oldpassword", None) oldpassword = data.get("oldpassword", None)
surepassword = data.get("surepassword", None) surepassword = data.get("surepassword", None)
mobile = data.get("mobile", None)
email = data.get("email", None)
if mobile or email:
is_valid = valid_captcha(data.get("cptch_key", None), data.get("authcode", None), request) is_valid = valid_captcha(data.get("cptch_key", None), data.get("authcode", None), request)
if not is_valid: if not is_valid:
res.code = 1008 res.code = 1008
@ -396,8 +399,7 @@ class UserInfoView(APIView):
act = data.get("act", None) act = data.get("act", None)
status, target = is_valid_sender_code(act, data.get("auth_token", None), data.get("auth_key", None)) status, target = is_valid_sender_code(act, data.get("auth_token", None), data.get("auth_key", None))
if status: if status:
mobile = data.get("mobile", None)
email = data.get("email", None)
if act == 'sms' and mobile: if act == 'sms' and mobile:
if str(target) == str(mobile): if str(target) == str(mobile):
if is_valid_phone(mobile): if is_valid_phone(mobile):

Loading…
Cancel
Save