fix some bugs

pull/1/head
xiaoyu 4 years ago
parent 11810cd6ca
commit 0521f0c6a0
  1. 5
      fir_client/src/components/FirAppInfosBase.vue
  2. 25
      fir_client/src/components/FirAppInfossecurity.vue
  3. 20
      fir_client/src/components/FirUserProfileInfo.vue
  4. 63
      fir_client/src/utils/index.js
  5. 13
      fir_ser/api/utils/storage/aliyunApi.py
  6. 2
      fir_ser/api/views/apps.py
  7. 17
      fir_ser/api/views/login.py
  8. 2
      fir_ser/api/views/storage.py

@ -160,7 +160,10 @@
}, watch: { }, watch: {
'$store.state.currentapp.master_release.icon_url': function () { '$store.state.currentapp.master_release.icon_url': function () {
this.icon_url = this.$store.state.currentapp.master_release.icon_url this.icon_url = this.$store.state.currentapp.master_release.icon_url
} },
'$store.state.currentapp': function () {
this.appinfos = this.$store.state.currentapp;
},
} }
} }

@ -125,6 +125,13 @@
} }
}, },
methods: { methods: {
set_default_flag() {
this.passwordflag = false;
this.showdownloadflag = false;
this.showsupersignflag = false;
this.wxeasytypeflag = false;
this.wxredirectflag = false;
},
clean_app() { clean_app() {
this.saveappinfo({"clean": true}); this.saveappinfo({"clean": true});
this.currentapp.count = 0; this.currentapp.count = 0;
@ -135,13 +142,7 @@
this.$message.success('数据更新成功'); this.$message.success('数据更新成功');
} else { } else {
this.$message.error('操作失败,' + data.msg); this.$message.error('操作失败,' + data.msg);
this.$store.dispatch('doucurrentapp', this.orgcurrentapp);
this.currentapp = deepCopy(this.orgcurrentapp);
this.passwordflag = false;
this.showdownloadflag = false;
this.showsupersignflag = false;
this.setbuttondefault(this.currentapp);
} }
}, { }, {
"methods": "PUT", "methods": "PUT",
@ -357,17 +358,11 @@
} }
}, },
appinit() { appinit() {
this.currentapp = this.$store.state.currentapp; this.currentapp = this.$store.state.currentapp;
this.passwordflag = false; this.set_default_flag();
this.showdownloadflag = false;
this.showsupersignflag = false;
this.wxeasytypeflag = false;
this.wxredirectflag = false;
this.setbuttondefault(this.currentapp); this.setbuttondefault(this.currentapp);
this.orgcurrentapp = deepCopy(this.currentapp) this.orgcurrentapp = deepCopy(this.currentapp);
} }
}, },
mounted() { mounted() {

@ -89,6 +89,7 @@
<script> <script>
import {userinfos} from '../restful' import {userinfos} from '../restful'
import {deepCopy} from "../utils";
export default { export default {
name: "FirUserProfileInfo", name: "FirUserProfileInfo",
@ -97,6 +98,7 @@
userinfo: { userinfo: {
srccode: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg', srccode: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg',
}, },
orguserinfo:{},
editphone: false, editphone: false,
editdomain_name: false, editdomain_name: false,
editposition: false editposition: false
@ -117,20 +119,29 @@
updateUserInfo(datainfo) { updateUserInfo(datainfo) {
userinfos(data => { userinfos(data => {
if (data.code === 1000) { if (data.code === 1000) {
this.userinfo = data.data; let phonenumber=null;
this.$store.dispatch("doUserinfo", data.data);
if (data.data.sms_code) { if (data.data.sms_code) {
phonenumber = this.userinfo.mobile;
this.$notify({ this.$notify({
title: '验证码', title: '验证码',
message: '您正在修改手机号码,验证码为:' + data.data.sms_code, message: '您正在修改手机号码,验证码为:' + data.data.sms_code,
type: 'success' type: 'success'
}); });
} }
this.userinfo = data.data;
this.$store.dispatch("doUserinfo", data.data);
this.orguserinfo = deepCopy(data.data);
if(phonenumber){
this.userinfo.mobile = phonenumber;
}
if (datainfo.data) { if (datainfo.data) {
this.$message.success("更新成功") this.$message.success("更新成功")
} }
} else { } else {
this.$message.error("更新失败 " + data.msg) this.$message.error("更新失败 " + data.msg);
this.$store.dispatch('doUserinfo', this.orguserinfo);
} }
}, datainfo) }, datainfo)
@ -169,10 +180,13 @@
this.$store.dispatch('douserInfoIndex', 0); this.$store.dispatch('douserInfoIndex', 0);
// this.updateUserInfo({"methods":false}); // this.updateUserInfo({"methods":false});
this.userinfo = this.$store.state.userinfo; this.userinfo = this.$store.state.userinfo;
this.orguserinfo = deepCopy(this.$store.state.userinfo);
}, watch: { }, watch: {
'$store.state.userinfo': function () { '$store.state.userinfo': function () {
this.userinfo = this.$store.state.userinfo; this.userinfo = this.$store.state.userinfo;
this.orguserinfo = deepCopy(this.$store.state.userinfo);
} }
} }
} }

@ -196,14 +196,19 @@ export function removeAaary(_arr, _obj) {
} }
} }
//深拷贝 //深拷贝-字段不能为null
export function deepCopy(source) { // export function deepCopy(source) {
let result = {}; // let result = {};
for (let key in source) { // for (let key in source) {
result[key] = typeof source[key] === 'object' ? deepCopy(source[key]) : source[key]; // result[key] = typeof source[key] === 'object' ? deepCopy(source[key]) : source[key];
} // }
return result; // return result;
} // }
//
// //深拷贝-只有json
// export function deepCopyJson(source) {
// return JSON.parse(JSON.stringify(source))
// }
export function IsNum(s) { export function IsNum(s) {
if (s != null) { if (s != null) {
@ -214,3 +219,45 @@ export function IsNum(s) {
} }
return false; return false;
} }
function getType(x) {
if (x) {
if (x.constructor.toString().indexOf("Array") > -1) {
return 'array'
} else if (x.constructor.toString().indexOf("Number") > -1) {
return 'number'
} else if (x.constructor.toString().indexOf("String") > -1) {
return 'string'
} else if (x.constructor.toString().indexOf("Object") > -1) {
return 'object'
} else {
return x.constructor.toString()
}
} else {
return x
}
}
//深拷贝
export function deepCopy(data) {
let type = getType(data);
let obj;
if (type === 'array') {
obj = [];
} else if (type === 'object') {
obj = {};
} else {
//不再具有下一层次
return data;
}
if (type === 'array') {
for (let i = 0, len = data.length; i < len; i++) {
obj.push(deepCopy(data[i]));
}
} else if (type === 'object') {
for (let key in data) {
obj[key] = deepCopy(data[key]);
}
}
return obj;
}

@ -127,10 +127,11 @@ class AliYunOss(object):
def upload_file(self, local_file_full_path): def upload_file(self, local_file_full_path):
if os.path.isfile(local_file_full_path): if os.path.isfile(local_file_full_path):
with open(local_file_full_path, 'rb') as fileobj: self.bucket.put_object_from_file(os.path.basename(local_file_full_path), local_file_full_path)
# Seek方法用于指定从第1000个字节位置开始读写。上传时会从您指定的第1000个字节位置开始上传,直到文件结束。 # with open(local_file_full_path, 'rb') as fileobj:
fileobj.seek(1000, os.SEEK_SET) # # Seek方法用于指定从第1000个字节位置开始读写。上传时会从您指定的第1000个字节位置开始上传,直到文件结束。
# Tell方法用于返回当前位置。 # fileobj.seek(1000, os.SEEK_SET)
# current = fileobj.tell() # # Tell方法用于返回当前位置。
self.bucket.put_object(os.path.basename(local_file_full_path), fileobj) # # current = fileobj.tell()
# self.bucket.put_object(os.path.basename(local_file_full_path), fileobj)
return True return True

@ -192,7 +192,7 @@ class AppInfoView(APIView):
apps_obj.wxeasytype = 1 apps_obj.wxeasytype = 1
apps_obj.wxredirect = data.get("wxredirect", apps_obj.wxredirect) apps_obj.wxredirect = data.get("wxredirect", apps_obj.wxredirect)
if apps_obj.type == 1: if apps_obj.type == 1 and data.get('issupersign', -1) != -1:
# 为啥注释掉,就是该udid已经在该平台使用了,虽然已经没有余额,但是其他应用也是可以超级签名的 # 为啥注释掉,就是该udid已经在该平台使用了,虽然已经没有余额,但是其他应用也是可以超级签名的
# developer_obj = AppIOSDeveloperInfo.objects.filter(user_id=request.user) # developer_obj = AppIOSDeveloperInfo.objects.filter(user_id=request.user)
# use_num = get_developer_devices(developer_obj) # use_num = get_developer_devices(developer_obj)

@ -5,7 +5,7 @@ from api.utils.serializer import UserInfoSerializer
from django.core.cache import cache from django.core.cache import cache
from rest_framework.views import APIView from rest_framework.views import APIView
import binascii import binascii
import os, datetime import os, datetime, re
from api.utils.utils import get_captcha, valid_captcha, is_valid_domain from api.utils.utils import get_captcha, valid_captcha, is_valid_domain
from api.utils.TokenManager import DownloadToken, generateNumericTokenOfLength from api.utils.TokenManager import DownloadToken, generateNumericTokenOfLength
from api.utils.auth import ExpiringTokenAuthentication from api.utils.auth import ExpiringTokenAuthentication
@ -83,6 +83,7 @@ class LoginView(APIView):
response.data = get_captcha() response.data = get_captcha()
return Response(response.dict) return Response(response.dict)
class RegistView(APIView): class RegistView(APIView):
def generate_key(self): def generate_key(self):
return binascii.hexlify(os.urandom(32)).decode() return binascii.hexlify(os.urandom(32)).decode()
@ -105,7 +106,8 @@ class RegistView(APIView):
response.msg = "邮箱已经存在,请更换其他邮箱" response.msg = "邮箱已经存在,请更换其他邮箱"
response.code = 1002 response.code = 1002
except UserInfo.DoesNotExist: except UserInfo.DoesNotExist:
user_obj = UserInfo.objects.create_user(username, email=username, password=password,first_name=username) user_obj = UserInfo.objects.create_user(username, email=username, password=password,
first_name=username[:8])
if user_obj: if user_obj:
response.msg = "注册成功" response.msg = "注册成功"
response.code = 1000 response.code = 1000
@ -128,7 +130,6 @@ class RegistView(APIView):
return Response(response.dict) return Response(response.dict)
class UserInfoView(APIView): class UserInfoView(APIView):
authentication_classes = [ExpiringTokenAuthentication, ] authentication_classes = [ExpiringTokenAuthentication, ]
@ -214,7 +215,15 @@ class UserInfoView(APIView):
if sms_token: if sms_token:
sms_token_obj = DownloadToken() sms_token_obj = DownloadToken()
if sms_token_obj.verify_token(sms_token, data.get("sms_code", None)): if sms_token_obj.verify_token(sms_token, data.get("sms_code", None)):
mobile = data.get("mobile", request.user.mobile)
phone_pat = re.compile('^(13\d|14[5|7]|15\d|166|17[3|6|7]|18\d)\d{8}$')
if mobile and re.search(phone_pat, mobile):
request.user.mobile = data.get("mobile", request.user.mobile) request.user.mobile = data.get("mobile", request.user.mobile)
else:
res.code = 1005
res.msg = "手机号校验失败"
return Response(res.dict)
try: try:
request.user.save() request.user.save()
except Exception as e: except Exception as e:
@ -222,7 +231,7 @@ class UserInfoView(APIView):
res.data = serializer.data res.data = serializer.data
res.code = 1004 res.code = 1004
res.msg = "信息保存失败" res.msg = "信息保存失败"
logger.error("User %s info save failed. Excepiton:%s" % (request.user,e)) logger.error("User %s info save failed. Excepiton:%s" % (request.user, e))
return Response(res.dict) return Response(res.dict)
serializer = UserInfoSerializer(request.user) serializer = UserInfoSerializer(request.user)
res.data = serializer.data res.data = serializer.data

@ -107,7 +107,7 @@ class StorageView(APIView):
storage_id = data.get("id", None) storage_id = data.get("id", None)
if storage_id: if storage_id:
if storage_id == request.user.storage.id: if request.user.storage and storage_id == request.user.storage.id:
res.msg = '存储正在使用中,无法修改' res.msg = '存储正在使用中,无法修改'
res.code = 1007 res.code = 1007
return Response(res.dict) return Response(res.dict)

Loading…
Cancel
Save