From 89370df9588b7d9eddf5f292213c38c75fd8c514 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Thu, 22 Apr 2021 14:53:23 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=99=BB=E5=BD=95=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=94=A8=E6=88=B7=E5=90=8D=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/dataease/auth/api/AuthApi.java | 5 +++++ .../io/dataease/auth/server/AuthServer.java | 9 ++++++++ .../auth/service/impl/ShiroServiceImpl.java | 1 + frontend/src/api/user.js | 8 +++++++ frontend/src/views/login/index.vue | 21 ++++++++++++++----- 5 files changed, 39 insertions(+), 5 deletions(-) diff --git a/backend/src/main/java/io/dataease/auth/api/AuthApi.java b/backend/src/main/java/io/dataease/auth/api/AuthApi.java index f3e2a977e0..e4872b8485 100644 --- a/backend/src/main/java/io/dataease/auth/api/AuthApi.java +++ b/backend/src/main/java/io/dataease/auth/api/AuthApi.java @@ -7,6 +7,8 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; +import java.util.Map; + @Api(tags = "权限:权限管理") @RequestMapping("/api/auth") @@ -26,6 +28,9 @@ public interface AuthApi { @PostMapping("/logout") String logout(); + @PostMapping("/validateName") + Boolean validateName(Map nameDto); + @GetMapping("/test") String test(); diff --git a/backend/src/main/java/io/dataease/auth/server/AuthServer.java b/backend/src/main/java/io/dataease/auth/server/AuthServer.java index a3a1640706..6c454034f7 100644 --- a/backend/src/main/java/io/dataease/auth/server/AuthServer.java +++ b/backend/src/main/java/io/dataease/auth/server/AuthServer.java @@ -82,6 +82,15 @@ public class AuthServer implements AuthApi { return "success"; } + @Override + public Boolean validateName(@RequestBody Map nameDto) { + String userName = nameDto.get("userName"); + if (StringUtils.isEmpty(userName)) return false; + SysUserEntity userEntity = authUserService.getUserByName(userName); + if (ObjectUtils.isEmpty(userEntity)) return false; + return true; + } + @Override public Boolean isLogin() { return null; diff --git a/backend/src/main/java/io/dataease/auth/service/impl/ShiroServiceImpl.java b/backend/src/main/java/io/dataease/auth/service/impl/ShiroServiceImpl.java index 782a5c6dd6..88f361fe18 100644 --- a/backend/src/main/java/io/dataease/auth/service/impl/ShiroServiceImpl.java +++ b/backend/src/main/java/io/dataease/auth/service/impl/ShiroServiceImpl.java @@ -49,6 +49,7 @@ public class ShiroServiceImpl implements ShiroService { filterChainDefinitionMap.put("/api/auth/login", ANON); + filterChainDefinitionMap.put("/api/auth/validateName", ANON); filterChainDefinitionMap.put("/unauth", ANON); filterChainDefinitionMap.put("/display/**", ANON); filterChainDefinitionMap.put("/tokenExpired", ANON); diff --git a/frontend/src/api/user.js b/frontend/src/api/user.js index d4676c5d13..fbe62b88a2 100644 --- a/frontend/src/api/user.js +++ b/frontend/src/api/user.js @@ -21,3 +21,11 @@ export function logout() { method: 'post' }) } + +export function validateUserName(data) { + return request({ + url: '/api/auth/validateName', + method: 'post', + data + }) +} diff --git a/frontend/src/views/login/index.vue b/frontend/src/views/login/index.vue index 6d0307d35b..9d1831faaa 100644 --- a/frontend/src/views/login/index.vue +++ b/frontend/src/views/login/index.vue @@ -49,17 +49,28 @@