Authored by htoooth

fix needlogin

... ... @@ -25,7 +25,7 @@ const request = async({url, method, reqParams = {}, context}) => {
},
sessionKey: user.sessionKey,
appSessionType: user.appSessionType
} : 1,
} : null,
method: apiInfo.api,
});
}
... ...
... ... @@ -143,7 +143,7 @@ export default {
this.toast && this.toast.hide();
if (result.code === 200) {
if (result && result.code === 200) {
this.$store.commit('license/form/FETCH_UFO_STATUS_SUCCESS', 0);
} else {
this.$createToast({
... ... @@ -186,11 +186,19 @@ export default {
this.model.certFaceImage.length === 1 &&
this.model.certReverseImage.length === 1 &&
(this.model.time.noLimit ? this.model.time.start_time : this.model.time.start_time && this.model.time.expire_time);
}
},
...mapState(['needLogin'])
},
mounted() {
this.fetchToken();
},
watch: {
needLogin(newVal) {
if (newVal) {
this.$yoho.goLogin({});
}
}
},
components: {
LayoutApp,
FixedBottom,
... ...
... ... @@ -30,16 +30,23 @@ export default {
},
async saveLicense({ commit }, data) {
const result = await this.$api.post(
'/api/ufo/license/save',
_handleData(data)
);
let result = {};
try {
result = await this.$api.post(
'/api/ufo/license/save',
_handleData(data)
);
} catch (e) {
commit(Types.FETCH_UFO_NEED_LOGIN, true);
return result;
}
return result;
},
async licenseStatus({ commit }) {
let result = null;
let result = {};
try {
result = await this.$api.get('/api/ufo/license/status');
... ... @@ -58,7 +65,13 @@ export default {
},
async getStoreStatus({ commit }) {
const result = await this.$api.get('/api/ufo/store/status');
let result = {};
try {
result = await this.$api.get('/api/ufo/store/status');
} catch (e) {
return result;
}
return result;
}
... ...
... ... @@ -7,25 +7,29 @@ const qiniu = require('qiniu');
const qiniuConfig = global.yoho.config.qiniu;
const qiniuYohoCdnConfig = global.yoho.config.qiniuYohoCdn;
function getToken(req, res) {
let conf = qiniuConfig;
let type = req.query.type || '';
function getToken(req, res, next) {
try {
let conf = qiniuConfig;
let type = req.query.type || '';
if (type.toLowerCase() === 'yohocdn') {
conf = qiniuYohoCdnConfig;
}
if (type.toLowerCase() === 'yohocdn') {
conf = qiniuYohoCdnConfig;
}
let mac = new qiniu.auth.digest.Mac(conf.ACCESS_KEY, conf.SECRET_KEY);
let options = {
scope: conf.BUCKET_NAME
};
let putPolicy = new qiniu.rs.PutPolicy(options);
let uploadToken = putPolicy.uploadToken(mac);
let mac = new qiniu.auth.digest.Mac(conf.ACCESS_KEY, conf.SECRET_KEY);
let options = {
scope: conf.BUCKET_NAME
};
let putPolicy = new qiniu.rs.PutPolicy(options);
let uploadToken = putPolicy.uploadToken(mac);
res.json({
code: 200,
uptoken: uploadToken
});
res.json({
code: 200,
uptoken: uploadToken
});
} catch (e) {
return next(e);
}
}
module.exports = {
... ...
... ... @@ -25,7 +25,7 @@ module.exports = async(req, res, next) => {
},
sessionKey: req.user.sessionKey,
appSessionType: req.user.appSessionType
} : 0,
} : null,
method: apiInfo.api
};
}
... ...