fix(XPack): license 验证缺陷修复

This commit is contained in:
fit2-zhao 2020-09-22 19:48:44 +08:00
parent d370a5bb7b
commit 8f807044ad
5 changed files with 38 additions and 38 deletions

View File

@ -127,10 +127,4 @@ public class APITestController {
public List<ScheduleDao> listSchedule(@RequestBody QueryScheduleRequest request) {
return apiTestService.listSchedule(request);
}
@GetMapping("/license/valid")
public LicenseDTO valid() {
return apiTestService.validateLicense();
}
}

View File

@ -437,13 +437,4 @@ public class APITestService {
quotaService.checkAPITestQuota();
}
}
public LicenseDTO validateLicense() {
LicenseService licenseService = CommonBeanFactory.getBean(LicenseService.class);
if (licenseService != null) {
return licenseService.valid();
}
return null;
}
}

View File

@ -5,6 +5,7 @@ import io.metersphere.commons.constants.UserSource;
import io.metersphere.commons.user.SessionUser;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.controller.request.LoginRequest;
import io.metersphere.dto.LicenseDTO;
import io.metersphere.service.UserService;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
@ -67,4 +68,9 @@ public class LoginController {
return userService.getDefaultLanguage();
}
@GetMapping("/api/license/valid")
public LicenseDTO valid() {
return userService.validateLicense();
}
}

View File

@ -10,6 +10,7 @@ import io.metersphere.commons.constants.UserStatus;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.user.SessionUser;
import io.metersphere.commons.utils.CodingUtil;
import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.controller.ResultHolder;
import io.metersphere.controller.request.LoginRequest;
@ -19,6 +20,7 @@ import io.metersphere.controller.request.member.QueryMemberRequest;
import io.metersphere.controller.request.member.UserRequest;
import io.metersphere.controller.request.organization.AddOrgMemberRequest;
import io.metersphere.controller.request.organization.QueryOrgMemberRequest;
import io.metersphere.dto.LicenseDTO;
import io.metersphere.dto.UserDTO;
import io.metersphere.dto.UserRoleDTO;
import io.metersphere.i18n.Translator;
@ -589,4 +591,12 @@ public class UserService {
public List<User> searchUser(String condition) {
return extUserMapper.searchUser(condition);
}
public LicenseDTO validateLicense() {
LicenseService licenseService = CommonBeanFactory.getBean(LicenseService.class);
if (licenseService != null) {
return licenseService.valid();
}
return null;
}
}

View File

@ -1,15 +1,11 @@
<template>
<el-col v-if="auth">
<el-row id="header-top1" type="flex" justify="space-between" align="middle">
<el-row v-if="licenseHeader != null">
<el-col>
<div class="license-head" v-if="validData.status == 'expired'">License has expired since
{{(validData!= undefined && validData.license!= undefined) ? validData.license.expired:''}},please
update license.
</div>
<component :is="licenseHeader"></component>
</el-col>
</el-row>
<el-row id="header-top" type="flex" justify="space-between" align="middle">
<el-col :span="12">
<a class="logo"/>
<ms-top-menus/>
@ -34,15 +30,18 @@
import MsHeaderOrgWs from "./components/common/head/HeaderOrgWs";
import MsLanguageSwitch from "./components/common/head/LanguageSwitch";
import {saveLocalStorage} from "../common/js/utils";
import {saveLicense} from "../common/js/utils";
import Setting from "@/business/components/settings/router";
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
const header = requireComponent("./license/LicenseMessage.vue");
export default {
name: 'app',
props: {},
data() {
return {
validData: {},
auth: false
licenseHeader: null,
auth: false,
header: {},
}
},
beforeCreate() {
@ -51,6 +50,10 @@
this.$setLang(response.data.data.language);
saveLocalStorage(response.data);
this.auth = true;
//
if (header.default !== undefined) {
this.licenseHeader = "MsLicenseHeader";
}
} else {
window.location.href = "/login"
}
@ -58,21 +61,18 @@
window.location.href = "/login"
});
},
beforeMount() {
// license
this.result = this.$get("/api/license/valid", response => {
let data = response.data;
if (data != undefined && data != null) {
this.validData = response.data;
saveLicense(response.data);
}
});
},
components: {MsLanguageSwitch, MsUser, MsView, MsTopMenus, MsHeaderOrgWs},
methods: {}
components: {
MsLanguageSwitch,
MsUser,
MsView,
MsTopMenus,
MsHeaderOrgWs,
"MsLicenseHeader": header.default
}
}
</script>
<style scoped>
#header-top {
width: 100%;
@ -128,4 +128,3 @@
color: white;
}
</style>