diff --git a/fir_client/src/components/FirBase.vue b/fir_client/src/components/FirBase.vue index 359c2bd..9f1246e 100644 --- a/fir_client/src/components/FirBase.vue +++ b/fir_client/src/components/FirBase.vue @@ -75,7 +75,7 @@ let canvas = this.$refs.canvas; show_beautpic(this, canvas, 200); }, watch: { - '$store.state.userinfo.domain_name': function () { + '$store.state.userinfo': function () { if (this.$store.state.userinfo.domain_name) { this.$store.dispatch("dodomainshow", false); } else { diff --git a/fir_client/src/components/FirLogin.vue b/fir_client/src/components/FirLogin.vue index c3f19aa..08fe9a8 100644 --- a/fir_client/src/components/FirLogin.vue +++ b/fir_client/src/components/FirLogin.vue @@ -68,6 +68,9 @@ 注册 + + 忘记密码 + diff --git a/fir_client/src/components/FirResetPwd.vue b/fir_client/src/components/FirResetPwd.vue new file mode 100644 index 0000000..5614010 --- /dev/null +++ b/fir_client/src/components/FirResetPwd.vue @@ -0,0 +1,235 @@ + + + + + diff --git a/fir_client/src/components/apps/FirAppInfossecurity.vue b/fir_client/src/components/apps/FirAppInfossecurity.vue index 369da9d..5536019 100644 --- a/fir_client/src/components/apps/FirAppInfossecurity.vue +++ b/fir_client/src/components/apps/FirAppInfossecurity.vue @@ -52,7 +52,7 @@ - 保存 + 设置域名 diff --git a/fir_client/src/components/base/BindDomain.vue b/fir_client/src/components/base/BindDomain.vue index 6b0b036..69836f1 100644 --- a/fir_client/src/components/base/BindDomain.vue +++ b/fir_client/src/components/base/BindDomain.vue @@ -166,7 +166,9 @@ if (data.code === 1000) { if (this.active++ > 2) this.active = 3; this.bind_status = true; - this.$store.dispatch("dodomainshow", false); + if (!this.app_id) { + this.$store.dispatch("dodomainshow", false); + } } else { if (data.code === 1004) { this.active = 1; @@ -185,7 +187,9 @@ this.bind_status = false; this.active = 1; this.$message.success("解除绑定成功 "); - this.$store.dispatch("dodomainshow", true); + if (!this.app_id) { + this.$store.dispatch("dodomainshow", true); + } } else { this.$message.error("解除绑定失败 " + data.msg) } diff --git a/fir_client/src/router/index.js b/fir_client/src/router/index.js index 136e930..0c6015b 100644 --- a/fir_client/src/router/index.js +++ b/fir_client/src/router/index.js @@ -145,6 +145,12 @@ const router = new VueRouter({ name: 'FirRegist', component: () => import("@/components/FirRegist"), + }, + { + path: '/reset/pwd', + name: 'FirResetPwd', + component: () => import("@/components/FirResetPwd"), + }, { path: '/:short', diff --git a/fir_ser/api/utils/baseutils.py b/fir_ser/api/utils/baseutils.py index b51731e..59a3d68 100644 --- a/fir_ser/api/utils/baseutils.py +++ b/fir_ser/api/utils/baseutils.py @@ -4,7 +4,7 @@ # author: NinEveN # date: 2021/4/16 -import os, re +import os, re, time from fir_ser.settings import SUPER_SIGN_ROOT from api.models import AppReleaseInfo, UserDomainInfo from api.utils.app.randomstrings import make_app_uuid @@ -106,17 +106,28 @@ def format_storage_selection(storage_info_list, storage_choice_list): def get_cname_from_domain(domain): + dns_list = [ + ["8.8.8.8", "8.8.4.4"], + ["119.29.29.29", "114.114.114.114"], + ["223.5.5.5", "223.6.6.6"], + ] dns_resolver = Resolver() - dns_resolver.nameservers = ["8.8.8.8", "8.8.4.4"] domain = domain.lower().strip() - try: - return dns_resolver.query(domain, 'CNAME')[0].to_text() - except Exception: + count = 3 + while count: + try: + dns_resolver.nameservers = dns_list[len(dns_list) - count] + return dns_resolver.query(domain, 'CNAME')[0].to_text() + except Exception as e: + logger.error("dns %s resolve %s failed Exception:%s" % (dns_resolver.nameservers, domain, e)) + count -= 1 + time.sleep(0.3) + if count <= 0: return str(None) def get_user_domain_name(obj): - domain_obj = UserDomainInfo.objects.filter(user_id=obj, is_enable=True).first() + domain_obj = UserDomainInfo.objects.filter(user_id=obj, is_enable=True, app_id=None).first() if domain_obj: return domain_obj.domain_name return '' diff --git a/fir_ser/api/views/apps.py b/fir_ser/api/views/apps.py index 59993ae..8677f48 100644 --- a/fir_ser/api/views/apps.py +++ b/fir_ser/api/views/apps.py @@ -18,7 +18,7 @@ from rest_framework.pagination import PageNumberPagination import logging from fir_ser.settings import SERVER_DOMAIN from api.utils.utils import delete_local_files, delete_app_screenshots_files -from api.utils.baseutils import is_valid_domain, get_user_domain_name +from api.utils.baseutils import is_valid_domain, get_user_domain_name, get_app_domain_name from api.base_views import app_delete logger = logging.getLogger(__name__) @@ -211,8 +211,7 @@ class AppInfoView(APIView): apps_obj.supersign_limit_number) apps_obj.isshow = data.get("isshow", apps_obj.isshow) - if get_user_domain_name(request.user) or ( - apps_obj.domain_name and len(apps_obj.domain_name) > 3): + if get_user_domain_name(request.user) or get_app_domain_name(apps_obj): apps_obj.wxeasytype = data.get("wxeasytype", apps_obj.wxeasytype) else: apps_obj.wxeasytype = 1 diff --git a/fir_ser/api/views/download.py b/fir_ser/api/views/download.py index 67d84ce..03f340d 100644 --- a/fir_ser/api/views/download.py +++ b/fir_ser/api/views/download.py @@ -20,7 +20,7 @@ from api.utils.serializer import AppsShortSerializer from api.models import Apps, AppReleaseInfo, APPToDeveloper, APPSuperSignUsedInfo from django.http import FileResponse import logging -from api.utils.baseutils import get_profile_full_path +from api.utils.baseutils import get_profile_full_path, get_app_domain_name from api.utils.throttle import VisitShortThrottle, InstallShortThrottle logger = logging.getLogger(__file__) @@ -181,7 +181,7 @@ class ShortDownloadView(APIView): "storage": Storage(app_obj.user_id)}) res.data = app_serializer.data res.udid = udid - res.domain_name = get_redirect_server_domain(request, app_obj.user_id, app_obj.domain_name) + res.domain_name = get_redirect_server_domain(request, app_obj.user_id, get_app_domain_name(app_obj)) return Response(res.dict) # key的设置 diff --git a/fir_ser/api/views/login.py b/fir_ser/api/views/login.py index 4d786bf..6c362ca 100644 --- a/fir_ser/api/views/login.py +++ b/fir_ser/api/views/login.py @@ -30,6 +30,16 @@ def get_register_type(): return REGISTER.get("register_type") +def reset_user_pwd(user, surepassword, oldpassword=''): + if user is not None: + user.set_password(surepassword) + user.save() + logger.info("user:%s change password success,old %s new %s" % (user, oldpassword, surepassword)) + for token_obj in Token.objects.filter(user=user): + cache.delete(token_obj.access_token) + token_obj.delete() + + def GetAuthenticate(target, password, act, allow_type): user_obj = None if act == 'email' and allow_type[act]: @@ -198,6 +208,24 @@ class LoginView(APIView): login_type = receive.get("login_type", None) if login_auth_failed("get", username): + if login_type == 'reset': + if is_valid_email(username): + user_obj = UserInfo.objects.filter(email=username).first() + if user_obj: + password = get_random_username()[:16] + msg = '您的新密码为 %s 请用新密码登录之后,及时修改密码' % password + a, b = get_sender_email_token('email', username, 'msg', msg) + if a and b: + reset_user_pwd(user_obj, password, oldpassword='') + login_auth_failed("del", username) + else: + response.code = 1002 + response.msg = "邮箱不存在" + else: + response.code = 1003 + response.msg = "无效邮箱" + return Response(response.dict) + password = receive.get("password") user = GetAuthenticate(username, password, login_type, get_login_type()) logger.info("username:%s password:%s" % (username, password))