From fe9d6a44c651a5fad6c368e4c4f6b51457766351 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Thu, 13 Feb 2020 11:21:12 +0800 Subject: [PATCH 1/3] workspace del confirm --- .../components/settings/Workspace.vue | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/frontend/src/performance/components/settings/Workspace.vue b/frontend/src/performance/components/settings/Workspace.vue index a006cedf56..f0e12604e5 100644 --- a/frontend/src/performance/components/settings/Workspace.vue +++ b/frontend/src/performance/components/settings/Workspace.vue @@ -13,15 +13,10 @@ - + @@ -88,9 +83,17 @@ // }); }, del(row) { - this.$get('/workspace/delete/' + row.id, () => { - Message.success('删除成功'); - this.list(); + this.$confirm('这个工作空间确定要删除吗?', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + this.$get('/workspace/delete/' + row.id, () => { + Message.success('删除成功'); + this.list(); + }); + }).catch(() => { + }); window.console.log(row); }, From 53979cc3b7fc18243fb9697056c4a7d801bb79bb Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Thu, 13 Feb 2020 11:51:42 +0800 Subject: [PATCH 2/3] login demo --- .../io/metersphere/security/ShiroDBRealm.java | 18 +++++++++++++++--- frontend/src/login/Login.vue | 8 +++++++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/backend/src/main/java/io/metersphere/security/ShiroDBRealm.java b/backend/src/main/java/io/metersphere/security/ShiroDBRealm.java index ae11bb25cb..02275b7c1a 100644 --- a/backend/src/main/java/io/metersphere/security/ShiroDBRealm.java +++ b/backend/src/main/java/io/metersphere/security/ShiroDBRealm.java @@ -1,6 +1,8 @@ package io.metersphere.security; +import io.metersphere.dto.UserDTO; +import io.metersphere.service.UserService; import io.metersphere.user.SessionUser; import org.apache.shiro.SecurityUtils; import org.apache.shiro.authc.*; @@ -10,6 +12,8 @@ import org.apache.shiro.subject.PrincipalCollection; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.annotation.Resource; + /** * 自定义Realm 注入service 可能会导致在 service的aop 失效,例如@Transactional, @@ -23,6 +27,8 @@ import org.slf4j.LoggerFactory; public class ShiroDBRealm extends AuthorizingRealm { private Logger logger = LoggerFactory.getLogger(ShiroDBRealm.class); + @Resource + private UserService userService; /** * 权限认证 @@ -40,10 +46,16 @@ public class ShiroDBRealm extends AuthorizingRealm { UsernamePasswordToken token = (UsernamePasswordToken) authenticationToken; String userId = token.getUsername(); String password = String.valueOf(token.getPassword()); - SessionUser sessionUser = new SessionUser(); + UserDTO user = userService.getUserDTO(userId); + String msg; + if (user == null) { + msg = "not exist user is trying to login, user:" + userId; + logger.warn(msg); + throw new UnknownAccountException(msg); + } + // TODO 密码验证,roles 等内容填充 - sessionUser.setName(userId); - sessionUser.setId(userId); + SessionUser sessionUser = SessionUser.fromUser(user); SecurityUtils.getSubject().getSession().setAttribute("user", sessionUser); return new SimpleAuthenticationInfo(userId, password, getName()); } diff --git a/frontend/src/login/Login.vue b/frontend/src/login/Login.vue index f8fb291c29..a3275f4705 100644 --- a/frontend/src/login/Login.vue +++ b/frontend/src/login/Login.vue @@ -41,6 +41,10 @@