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

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

@ -196,14 +196,19 @@ export function removeAaary(_arr, _obj) {
}
}
//深拷贝
export function deepCopy(source) {
let result = {};
for (let key in source) {
result[key] = typeof source[key] === 'object' ? deepCopy(source[key]) : source[key];
}
return result;
}
//深拷贝-字段不能为null
// export function deepCopy(source) {
// let result = {};
// for (let key in source) {
// result[key] = typeof source[key] === 'object' ? deepCopy(source[key]) : source[key];
// }
// return result;
// }
//
// //深拷贝-只有json
// export function deepCopyJson(source) {
// return JSON.parse(JSON.stringify(source))
// }
export function IsNum(s) {
if (s != null) {
@ -214,3 +219,45 @@ export function IsNum(s) {
}
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):
if os.path.isfile(local_file_full_path):
with open(local_file_full_path, 'rb') as fileobj:
# Seek方法用于指定从第1000个字节位置开始读写。上传时会从您指定的第1000个字节位置开始上传,直到文件结束。
fileobj.seek(1000, os.SEEK_SET)
# Tell方法用于返回当前位置。
# current = fileobj.tell()
self.bucket.put_object(os.path.basename(local_file_full_path), fileobj)
self.bucket.put_object_from_file(os.path.basename(local_file_full_path), local_file_full_path)
# with open(local_file_full_path, 'rb') as fileobj:
# # Seek方法用于指定从第1000个字节位置开始读写。上传时会从您指定的第1000个字节位置开始上传,直到文件结束。
# fileobj.seek(1000, os.SEEK_SET)
# # Tell方法用于返回当前位置。
# # current = fileobj.tell()
# self.bucket.put_object(os.path.basename(local_file_full_path), fileobj)
return True

@ -192,7 +192,7 @@ class AppInfoView(APIView):
apps_obj.wxeasytype = 1
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已经在该平台使用了,虽然已经没有余额,但是其他应用也是可以超级签名的
# developer_obj = AppIOSDeveloperInfo.objects.filter(user_id=request.user)
# use_num = get_developer_devices(developer_obj)

@ -5,7 +5,7 @@ from api.utils.serializer import UserInfoSerializer
from django.core.cache import cache
from rest_framework.views import APIView
import binascii
import os, datetime
import os, datetime, re
from api.utils.utils import get_captcha, valid_captcha, is_valid_domain
from api.utils.TokenManager import DownloadToken, generateNumericTokenOfLength
from api.utils.auth import ExpiringTokenAuthentication
@ -83,6 +83,7 @@ class LoginView(APIView):
response.data = get_captcha()
return Response(response.dict)
class RegistView(APIView):
def generate_key(self):
return binascii.hexlify(os.urandom(32)).decode()
@ -105,7 +106,8 @@ class RegistView(APIView):
response.msg = "邮箱已经存在,请更换其他邮箱"
response.code = 1002
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:
response.msg = "注册成功"
response.code = 1000
@ -128,7 +130,6 @@ class RegistView(APIView):
return Response(response.dict)
class UserInfoView(APIView):
authentication_classes = [ExpiringTokenAuthentication, ]
@ -214,7 +215,15 @@ class UserInfoView(APIView):
if sms_token:
sms_token_obj = DownloadToken()
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)
else:
res.code = 1005
res.msg = "手机号校验失败"
return Response(res.dict)
try:
request.user.save()
except Exception as e:
@ -222,7 +231,7 @@ class UserInfoView(APIView):
res.data = serializer.data
res.code = 1004
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)
serializer = UserInfoSerializer(request.user)
res.data = serializer.data

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

Loading…
Cancel
Save