From c14a8b24c3a38f11047a5be31a972e1dba2e1ea0 Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Mon, 8 Jun 2020 16:08:53 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E8=A7=92=E8=89=B2?= =?UTF-8?q?=E6=97=B6=E5=88=A4=E6=96=AD=E6=98=AF=E5=90=A6=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E6=B8=85=E7=A9=BAlastWsId=E5=92=8ClastOrgId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/metersphere/service/UserService.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/backend/src/main/java/io/metersphere/service/UserService.java b/backend/src/main/java/io/metersphere/service/UserService.java index 00388570b0..2c8815b1db 100644 --- a/backend/src/main/java/io/metersphere/service/UserService.java +++ b/backend/src/main/java/io/metersphere/service/UserService.java @@ -195,6 +195,17 @@ public class UserService { String userId = user.getId(); UserRoleExample userRoleExample = new UserRoleExample(); userRoleExample.createCriteria().andUserIdEqualTo(userId); + List userRoles = userRoleMapper.selectByExample(userRoleExample); + List list = userRoles.stream().map(UserRole::getSourceId).collect(Collectors.toList()); + + if (!CollectionUtils.isEmpty(list)) { + if (list.contains(user.getLastWorkspaceId()) || list.contains(user.getLastOrganizationId())) { + user.setLastOrganizationId(""); + user.setLastWorkspaceId(""); + userMapper.updateByPrimaryKeySelective(user); + } + } + userRoleMapper.deleteByExample(userRoleExample); List> roles = user.getRoles(); if (!roles.isEmpty()) { @@ -275,6 +286,14 @@ public class UserService { UserRoleExample example = new UserRoleExample(); example.createCriteria().andRoleIdLike("%test%") .andUserIdEqualTo(userId).andSourceIdEqualTo(workspaceId); + + User user = userMapper.selectByPrimaryKey(userId); + if (StringUtils.equals(workspaceId, user.getLastWorkspaceId())) { + user.setLastWorkspaceId(""); + user.setLastOrganizationId(""); + userMapper.updateByPrimaryKeySelective(user); + } + userRoleMapper.deleteByExample(example); } @@ -305,6 +324,14 @@ public class UserService { public void delOrganizationMember(String organizationId, String userId) { UserRoleExample userRoleExample = new UserRoleExample(); userRoleExample.createCriteria().andRoleIdLike("%org%").andUserIdEqualTo(userId).andSourceIdEqualTo(organizationId); + + User user = userMapper.selectByPrimaryKey(userId); + if (StringUtils.equals(organizationId, user.getLastOrganizationId())) { + user.setLastWorkspaceId(""); + user.setLastOrganizationId(""); + userMapper.updateByPrimaryKeySelective(user); + } + userRoleMapper.deleteByExample(userRoleExample); } From b130c1ffa4df3dabc5a7b05000f295b87088c6ce Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Mon, 8 Jun 2020 16:08:59 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dsql=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/metersphere/service/OrganizationService.java | 4 ++++ frontend/src/business/components/settings/system/User.vue | 4 ++-- frontend/src/common/js/ajax.js | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/io/metersphere/service/OrganizationService.java b/backend/src/main/java/io/metersphere/service/OrganizationService.java index 0d354c7f39..a88e4f7b31 100644 --- a/backend/src/main/java/io/metersphere/service/OrganizationService.java +++ b/backend/src/main/java/io/metersphere/service/OrganizationService.java @@ -123,6 +123,10 @@ public class OrganizationService { list.add(r.getParentId()); } }); + + // ignore list size is 0 + list.add("no_such_id"); + OrganizationExample organizationExample = new OrganizationExample(); organizationExample.createCriteria().andIdIn(list); return organizationMapper.selectByExample(organizationExample); diff --git a/frontend/src/business/components/settings/system/User.vue b/frontend/src/business/components/settings/system/User.vue index 44080272a7..3881cac0c7 100644 --- a/frontend/src/business/components/settings/system/User.vue +++ b/frontend/src/business/components/settings/system/User.vue @@ -336,11 +336,11 @@ rule: { id: [ {required: true, message: this.$t('user.input_id'), trigger: 'blur'}, - {min: 2, max: 20, message: this.$t('commons.input_limit', [2, 20]), trigger: 'blur'} + {min: 2, max: 50, message: this.$t('commons.input_limit', [2, 50]), trigger: 'blur'} ], name: [ {required: true, message: this.$t('user.input_name'), trigger: 'blur'}, - {min: 2, max: 20, message: this.$t('commons.input_limit', [2, 20]), trigger: 'blur'}, + {min: 2, max: 50, message: this.$t('commons.input_limit', [2, 50]), trigger: 'blur'}, { required: true, pattern: /^[\u4e00-\u9fa5_a-zA-Z0-9.ยท-]+$/, diff --git a/frontend/src/common/js/ajax.js b/frontend/src/common/js/ajax.js index 3ce85b05e0..af0021d005 100644 --- a/frontend/src/common/js/ajax.js +++ b/frontend/src/common/js/ajax.js @@ -18,6 +18,8 @@ export default { let login = function () { MessageBox.alert(i18n.t('commons.tips'), i18n.t('commons.prompt'), { callback: () => { + axios.get("/signout"); + localStorage.setItem('Admin-Token', "{}"); window.location.href = "/login" } }); From 2a8fab75f06e8f5df6f72014e31229d74944d2d4 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Mon, 8 Jun 2020 16:15:13 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E7=94=A8=E5=88=B0=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/settings/system/TestResourcePool.vue | 6 ------ 1 file changed, 6 deletions(-) diff --git a/frontend/src/business/components/settings/system/TestResourcePool.vue b/frontend/src/business/components/settings/system/TestResourcePool.vue index f502006d92..40ad3daf11 100644 --- a/frontend/src/business/components/settings/system/TestResourcePool.vue +++ b/frontend/src/business/components/settings/system/TestResourcePool.vue @@ -301,9 +301,6 @@ }); }, createTestResourcePool(createTestResourcePoolForm) { - if (this.result.loading) { - return; - } this.$refs[createTestResourcePoolForm].validate(valid => { if (valid) { let vri = this.validateResourceInfo(); @@ -340,9 +337,6 @@ this.form.resources = resources; }, updateTestResourcePool(updateTestResourcePoolForm) { - if (this.result.loading) { - return; - } this.$refs[updateTestResourcePoolForm].validate(valid => { if (valid) { let vri = this.validateResourceInfo();