Browse Source

'打包配置'

yq 2 years ago
parent
commit
29e8addefc

+ 1 - 0
eladmin-system/pom.xml

@@ -97,6 +97,7 @@
 
     <!-- 打包 -->
     <build>
+        <finalName>wyxt</finalName>
         <plugins>
             <plugin>
                 <groupId>org.springframework.boot</groupId>

+ 26 - 0
eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthorizationController.java

@@ -133,6 +133,32 @@ public class AuthorizationController {
         return ResponseEntity.ok(authInfo);
     }
 
+
+
+    @ApiOperation("登录授权")
+    @AnonymousPostMapping(value = "/login3")
+    public ResponseEntity<Object> login3(@Validated @RequestBody AuthUserDto authUser, HttpServletRequest request) throws Exception {
+        UsernamePasswordAuthenticationToken authenticationToken =
+                new UsernamePasswordAuthenticationToken(authUser.getUsername(), authUser.getPassword());
+        Authentication authentication = authenticationManagerBuilder.getObject().authenticate(authenticationToken);
+        SecurityContextHolder.getContext().setAuthentication(authentication);
+        // 生成令牌
+        String token = tokenProvider.createToken(authentication);
+        final JwtUserDto jwtUserDto = (JwtUserDto) authentication.getPrincipal();
+        // 保存在线信息
+        onlineUserService.save(jwtUserDto, token, request);
+        // 返回 token 与 用户信息
+        Map<String, Object> authInfo = new HashMap<String, Object>(2) {{
+            put("token", properties.getTokenStartWith() + token);
+            put("user", jwtUserDto);
+        }};
+        if (loginProperties.isSingleLogin()) {
+            //踢掉之前已经登录的token
+            onlineUserService.checkLoginOnUser(authUser.getUsername(), token);
+        }
+        return ResponseEntity.ok(authInfo);
+    }
+
     @ApiOperation("获取用户信息")
     @GetMapping(value = "/info")
     public ResponseEntity<Object> getUserInfo() {

+ 3 - 3
eladmin-system/src/main/resources/config/application.yml

@@ -26,11 +26,11 @@ spring:
     database: ${REDIS_DB:0}
 #    host: ${REDIS_HOST:172.16.159.48}
 #    port: ${REDIS_PORT:6383}
-    host: ${REDIS_HOST:10.21.39.1}
-    port: ${REDIS_PORT:6388}
+    host: ${REDIS_HOST:47.111.81.118}
+    port: ${REDIS_PORT:6379}
 #    host: ${REDIS_HOST:127.0.0.1}
 #    port: ${REDIS_PORT:6379}
-    password: ${REDIS_PWD:UCSNxJ@k}
+    password: ${REDIS_PWD:uskyredis}
     #连接超时时间
     timeout: 5000