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):