From d805283ef26d2e3e8e67f64bb6c9ec3e66056182 Mon Sep 17 00:00:00 2001 From: xiaoyu Date: Fri, 25 Sep 2020 18:28:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=82=AE=E7=AE=B1=E5=92=8C?= =?UTF-8?q?=E6=89=8B=E6=9C=BA=E5=8F=B7=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/FirUserProfileInfo.vue | 56 ++++++++++++++----- fir_ser/api/urls.py | 4 +- fir_ser/api/views/login.py | 16 +++--- 3 files changed, 54 insertions(+), 22 deletions(-) diff --git a/fir_client/src/components/FirUserProfileInfo.vue b/fir_client/src/components/FirUserProfileInfo.vue index d969dea..0e48bff 100644 --- a/fir_client/src/components/FirUserProfileInfo.vue +++ b/fir_client/src/components/FirUserProfileInfo.vue @@ -44,6 +44,21 @@ + + + + + + + + + + + + @@ -185,7 +200,6 @@ if (data.code === 1000) { this.cptch = data.data; this.userinfo.cptch_key = this.cptch.cptch_key; - } else { this.$message({ message: data.msg, @@ -197,31 +211,46 @@ "data": {} }); }, - saveemail() { - this.updateUserInfo({"methods": 'PUT', 'data': this.userinfo}); - this.changeemailValue() - }, + 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() }, saveDomain() { - this.updateUserInfo({"methods": 'PUT', 'data': this.userinfo}); + this.updateUserInfo({"methods": 'PUT', 'data': {domain_name:this.userinfo.domain_name}}); this.changeDomainValue() }, savePositionValue() { - this.updateUserInfo({"methods": 'PUT', 'data': this.userinfo}); + this.updateUserInfo({"methods": 'PUT', 'data': {job:this.userinfo.job}}); 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() { - this.updateUserInfo({"methods": 'PUT', 'data': this.userinfo}); + let data = this.authinfo(); + data.mobile = this.userinfo.mobile; + this.updateUserInfo({"methods": 'PUT', 'data': data}); this.changePhoneValue() }, + updateUserInfo(datainfo) { - if (datainfo.data.username.toString().length < 6) { - this.$message.error("密码至少6位"); - return - } + userinfos(data => { if (data.code === 1000) { @@ -264,6 +293,7 @@ }, changePhoneValue() { + this.get_auth_code(); this.editphone = !this.editphone; if (this.$refs.phone.$el.children[0].style.backgroundColor) { this.$refs.phone.$el.children[0].style.backgroundColor = '' diff --git a/fir_ser/api/urls.py b/fir_ser/api/urls.py index 9d640a6..695353e 100644 --- a/fir_ser/api/urls.py +++ b/fir_ser/api/urls.py @@ -32,8 +32,8 @@ from api.views.supersign import DeveloperView, SuperSignUsedView, AppUDIDUsedVie urlpatterns = [ # path("",include(router.urls)), re_path("^login", LoginView.as_view()), - re_path("^auth", AuthorizationView.as_view()), - re_path("^authc", ChangeAuthorizationView.as_view()), + re_path("^auth$", AuthorizationView.as_view()), + re_path("^authc$", ChangeAuthorizationView.as_view()), re_path("^register", RegistView.as_view()), re_path("^logout", LogoutView.as_view()), re_path("^apps$", AppsView.as_view()), diff --git a/fir_ser/api/views/login.py b/fir_ser/api/views/login.py index 7f6e028..65247da 100644 --- a/fir_ser/api/views/login.py +++ b/fir_ser/api/views/login.py @@ -319,11 +319,14 @@ class UserInfoView(APIView): oldpassword = data.get("oldpassword", None) surepassword = data.get("surepassword", None) - is_valid = valid_captcha(data.get("cptch_key", None), data.get("authcode", None), request) - if not is_valid: - res.code = 1008 - res.msg = "图片验证码异常" - return Response(res.dict) + 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) + if not is_valid: + res.code = 1008 + res.msg = "图片验证码异常" + return Response(res.dict) if oldpassword and surepassword: user = auth.authenticate(username=request.user.username, password=oldpassword) @@ -396,8 +399,7 @@ class UserInfoView(APIView): act = data.get("act", None) status, target = is_valid_sender_code(act, data.get("auth_token", None), data.get("auth_key", None)) if status: - mobile = data.get("mobile", None) - email = data.get("email", None) + if act == 'sms' and mobile: if str(target) == str(mobile): if is_valid_phone(mobile):