增加应用专属域名功能

super_sign_new 6.1.1
nineven 4 years ago
parent 6e66592ba2
commit 0f1b7c39b4
  1. 3
      fir_client/src/components/FirAppInfosBase.vue
  2. 20
      fir_client/src/components/FirAppInfossecurity.vue
  3. 23
      fir_ser/api/migrations/0013_auto_20210128_1815.py
  4. 3
      fir_ser/api/models.py
  5. 7
      fir_ser/api/utils/app/supersignutils.py
  6. 2
      fir_ser/api/utils/serializer.py
  7. 9
      fir_ser/api/utils/storage/caches.py
  8. 40
      fir_ser/api/views/apps.py
  9. 2
      fir_ser/api/views/download.py

@ -137,7 +137,8 @@
} }
}, },
appDownload() { appDownload() {
this.$router.push({name: 'FirDownload', params: {short: this.appinfos.short}}) window.open(location.origin + '/' + this.appinfos.short,'target','');
// this.$router.push({name: 'FirDownload', params: {short: this.appinfos.short}})
}, },
defaulttimeline() { defaulttimeline() {
this.setfunactive('timeline', 5); this.setfunactive('timeline', 5);

@ -41,6 +41,13 @@
<el-link :underline="false" style="margin-left: 20px">默认开启关闭之后用户无法通过短连接访问下载该应用</el-link> <el-link :underline="false" style="margin-left: 20px">默认开启关闭之后用户无法通过短连接访问下载该应用</el-link>
</el-form-item> </el-form-item>
<el-form-item label-width="200px" label="应用专属域名">
<el-input v-model="currentapp.domain_name" clearable
style="width: 60%;margin-right: 10px" prefix-icon="el-icon-download"
:placeholder="defualt_dtitle"/>
<el-button @click="save_app_domain()">保存</el-button>
</el-form-item>
<el-form-item v-if="currentapp.type === 1 && $store.state.userinfo.supersign_active" label-width="200px" <el-form-item v-if="currentapp.type === 1 && $store.state.userinfo.supersign_active" label-width="200px"
label="自动超级签名"> label="自动超级签名">
@ -122,7 +129,8 @@
wxeasytypeflag: false, wxeasytypeflag: false,
wxredirectflag: false, wxredirectflag: false,
clecount: 0, clecount: 0,
wxeasy_disable: false wxeasy_disable: false,
defualt_dtitle: '专属下载页域名',
} }
}, },
methods: { methods: {
@ -137,6 +145,11 @@
this.saveappinfo({"clean": true}); this.saveappinfo({"clean": true});
this.currentapp.count = 0; this.currentapp.count = 0;
}, },
save_app_domain() {
this.saveappinfo({
"domain_name": this.currentapp.domain_name,
});
},
saveappinfo(data) { saveappinfo(data) {
apputils(data => { apputils(data => {
if (data.code === 1000) { if (data.code === 1000) {
@ -364,6 +377,11 @@
this.set_default_flag(); this.set_default_flag();
this.setbuttondefault(this.currentapp); this.setbuttondefault(this.currentapp);
this.orgcurrentapp = deepCopy(this.currentapp); this.orgcurrentapp = deepCopy(this.currentapp);
if(!this.currentapp.domain_name || this.currentapp.domain_name.length < 3){
if(this.$store.state.userinfo.domain_name && this.$store.state.userinfo.domain_name.length > 3){
this.defualt_dtitle = this.$store.state.userinfo.domain_name;
}
}
} }
}, },
mounted() { mounted() {

@ -0,0 +1,23 @@
# Generated by Django 3.0.3 on 2021-01-28 18:15
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('api', '0012_auto_20210127_2101'),
]
operations = [
migrations.AddField(
model_name='apps',
name='domain_name',
field=models.CharField(blank=True, max_length=64, null=True, verbose_name='专属访问域名'),
),
migrations.AlterField(
model_name='apps',
name='wxeasytype',
field=models.BigIntegerField(default=True, verbose_name='微信内简易模式,避免微信封停'),
),
]

@ -114,7 +114,8 @@ class Apps(models.Model):
isshow = models.BigIntegerField(verbose_name="下载页可见", default=1) isshow = models.BigIntegerField(verbose_name="下载页可见", default=1)
issupersign = models.BigIntegerField(verbose_name="是否超级签名包", default=False) issupersign = models.BigIntegerField(verbose_name="是否超级签名包", default=False)
wxredirect = models.BigIntegerField(verbose_name="微信内第三方链接自动跳转", default=True) wxredirect = models.BigIntegerField(verbose_name="微信内第三方链接自动跳转", default=True)
wxeasytype = models.BigIntegerField(verbose_name="微信内简易房屋,避免微信封停", default=True) wxeasytype = models.BigIntegerField(verbose_name="微信内简易模式,避免微信封停", default=True)
domain_name = models.CharField(verbose_name="专属访问域名", blank=True, null=True, max_length=64)
description = models.TextField('描述', blank=True, null=True, default=None, ) description = models.TextField('描述', blank=True, null=True, default=None, )
updated_time = models.DateTimeField(auto_now=True, verbose_name="更新时间") updated_time = models.DateTimeField(auto_now=True, verbose_name="更新时间")

@ -136,9 +136,12 @@ def get_http_server_doamin(request):
return server_domain return server_domain
def get_redirect_server_domain(request, user_obj=None): def get_redirect_server_domain(request, user_obj=None, app_domain_name=None):
if user_obj: if user_obj:
domain_name = user_obj.domain_name if app_domain_name and len(app_domain_name) > 3:
domain_name = app_domain_name
else:
domain_name = user_obj.domain_name
else: else:
domain_name = None domain_name = None
if domain_name and len(domain_name) > 3: if domain_name and len(domain_name) > 3:

@ -88,7 +88,7 @@ class AppsShortSerializer(serializers.ModelSerializer):
class Meta: class Meta:
model = models.Apps model = models.Apps
fields = ["app_id", "name", "short", "has_combo", "isshow", "description", "need_password", 'master_release', fields = ["app_id", "name", "short", "has_combo", "isshow", "description", "need_password", 'master_release',
'type', 'issupersign', 'wxeasytype', 'wxredirect'] 'type', 'issupersign', 'wxeasytype', 'wxredirect', 'domain_name']
need_password = serializers.SerializerMethodField() need_password = serializers.SerializerMethodField()

@ -253,7 +253,10 @@ def login_auth_failed(act, email):
cache.delete(auth_code_key) cache.delete(auth_code_key)
def set_default_app_wx_easy(user_obj): def set_default_app_wx_easy(user_obj, app_obj=None):
app_obj_lists = Apps.objects.filter(user_id=user_obj) if app_obj:
for app_obj in app_obj_lists:
del_cache_response_by_short(app_obj.app_id) del_cache_response_by_short(app_obj.app_id)
else:
app_obj_lists = Apps.objects.filter(user_id=user_obj)
for app_obj in app_obj_lists:
del_cache_response_by_short(app_obj.app_id)

@ -16,7 +16,9 @@ from api.models import Apps, AppReleaseInfo, APPToDeveloper, AppIOSDeveloperInfo
from api.utils.serializer import AppsSerializer, AppReleaseSerializer, UserInfoSerializer from api.utils.serializer import AppsSerializer, AppReleaseSerializer, UserInfoSerializer
from rest_framework.pagination import PageNumberPagination from rest_framework.pagination import PageNumberPagination
import logging import logging
from fir_ser.settings import CACHE_KEY_TEMPLATE, SERVER_DOMAIN, REGISTER, LOGIN
from api.utils.storage.caches import set_default_app_wx_easy
from api.utils.utils import is_valid_domain
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -152,6 +154,7 @@ class AppInfoView(APIView):
return Response(res.dict) return Response(res.dict)
has_combo = data.get("has_combo", None) has_combo = data.get("has_combo", None)
domain_name = data.get("domain_name", None)
if has_combo: if has_combo:
actions = has_combo.get("action", None) actions = has_combo.get("action", None)
hcombo_id = has_combo.get("hcombo_id", None) hcombo_id = has_combo.get("hcombo_id", None)
@ -177,6 +180,40 @@ class AppInfoView(APIView):
logger.error("app_id:%s actions:%s hcombo_id:%s Exception:%s" % (app_id, actions, hcombo_id, e)) logger.error("app_id:%s actions:%s hcombo_id:%s Exception:%s" % (app_id, actions, hcombo_id, e))
res.code = 1004 res.code = 1004
res.msg = "该应用已经关联" res.msg = "该应用已经关联"
elif domain_name:
apps_obj = Apps.objects.filter(user_id=request.user, app_id=app_id).first()
logger.info("app_id:%s update old data:%s" % (app_id, apps_obj.__dict__))
if domain_name:
domain_name_list = domain_name.strip(' ').replace("http://", "").replace("https://", "").split("/")
if len(domain_name_list) > 0:
domain_name = domain_name_list[0]
if len(domain_name) > 3 and is_valid_domain(domain_name_list[0]):
if domain_name == SERVER_DOMAIN.get("REDIRECT_UDID_DOMAIN").split("//")[1]:
admin_storage = UserInfo.objects.filter(is_superuser=True).order_by('pk').first()
if admin_storage and admin_storage.uid == request.user.uid:
apps_obj.domain_name = domain_name
set_default_app_wx_easy(request.user, apps_obj)
else:
serializer = UserInfoSerializer(request.user)
res.data = serializer.data
res.code = 1004
res.msg = "域名设置失败,请更换其他域名"
return Response(res.dict)
else:
apps_obj.domain_name = domain_name
set_default_app_wx_easy(request.user, apps_obj)
else:
res.code = 1004
res.msg = "域名校验失败"
return Response(res.dict)
if domain_name == '':
apps_obj.domain_name = None
apps_obj.wxeasytype = True
set_default_app_wx_easy(request.user, apps_obj)
apps_obj.save()
del_cache_response_by_short(apps_obj.app_id)
return Response(res.dict)
else: else:
try: try:
apps_obj = Apps.objects.filter(user_id=request.user, app_id=app_id).first() apps_obj = Apps.objects.filter(user_id=request.user, app_id=app_id).first()
@ -186,6 +223,7 @@ class AppInfoView(APIView):
apps_obj.name = data.get("name", apps_obj.name) apps_obj.name = data.get("name", apps_obj.name)
apps_obj.password = data.get("password", apps_obj.password) apps_obj.password = data.get("password", apps_obj.password)
apps_obj.isshow = data.get("isshow", apps_obj.isshow) apps_obj.isshow = data.get("isshow", apps_obj.isshow)
apps_obj.domain_name = data.get("domain_name", apps_obj.domain_name)
if request.user.domain_name and len(request.user.domain_name) > 3: if request.user.domain_name and len(request.user.domain_name) > 3:
apps_obj.wxeasytype = data.get("wxeasytype", apps_obj.wxeasytype) apps_obj.wxeasytype = data.get("wxeasytype", apps_obj.wxeasytype)
else: else:

@ -162,7 +162,7 @@ class ShortDownloadView(APIView):
"storage": Storage(app_obj.user_id)}) "storage": Storage(app_obj.user_id)})
res.data = app_serializer.data res.data = app_serializer.data
res.udid = udid res.udid = udid
res.domain_name = get_redirect_server_domain(request, app_obj.user_id) res.domain_name = get_redirect_server_domain(request, app_obj.user_id, app_serializer.data['domain_name'])
return Response(res.dict) return Response(res.dict)
# key的设置 # key的设置

Loading…
Cancel
Save