|
@@ -353,42 +353,50 @@ public class AdminAuthServiceImpl implements AdminAuthService {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public AuthLoginRespVO loginByAppToken(AuthAppTokenLoginReqVO reqVO) {
|
|
public AuthLoginRespVO loginByAppToken(AuthAppTokenLoginReqVO reqVO) {
|
|
|
- HttpHeaders httpHeaders = new HttpHeaders();
|
|
|
|
|
- httpHeaders.add("Authorization", "Bearer " + reqVO.getAppToken());
|
|
|
|
|
- httpHeaders.add("Content-Type", "application/json");
|
|
|
|
|
-
|
|
|
|
|
- HttpEntity<Object> req = new HttpEntity<>(null, httpHeaders);
|
|
|
|
|
- String baseUrl = "https://cloud-admin-uat.gzsei.com";
|
|
|
|
|
- // 使用 token 交换用户信息
|
|
|
|
|
- ResponseEntity<String> yiqunResp = restTemplate.postForEntity(baseUrl + "/external-api/system/auth/app-auth", req, String.class);
|
|
|
|
|
- AuthYiqunUserDTO user = null;
|
|
|
|
|
- if (!yiqunResp.getStatusCode().equals(HttpStatus.OK)) {
|
|
|
|
|
- log.warn("[authenticate] APPToken 无效");
|
|
|
|
|
- } else {
|
|
|
|
|
- String json = yiqunResp.getBody();
|
|
|
|
|
- try {
|
|
|
|
|
- JsonNode jsonNode = objectMapper.readTree(json);
|
|
|
|
|
- user = objectMapper.convertValue(jsonNode.get("data"), AuthYiqunUserDTO.class);
|
|
|
|
|
- } catch (JsonProcessingException e) {
|
|
|
|
|
- throw new RuntimeException(e);
|
|
|
|
|
|
|
+// HttpHeaders httpHeaders = new HttpHeaders();
|
|
|
|
|
+// httpHeaders.add("Authorization", "Bearer " + reqVO.getAppToken());
|
|
|
|
|
+// httpHeaders.add("Content-Type", "application/json");
|
|
|
|
|
+//
|
|
|
|
|
+// HttpEntity<Object> req = new HttpEntity<>(null, httpHeaders);
|
|
|
|
|
+// String baseUrl = "https://cloud-admin-uat.gzsei.com";
|
|
|
|
|
+// // 使用 token 交换用户信息
|
|
|
|
|
+// ResponseEntity<String> yiqunResp = restTemplate.postForEntity(baseUrl + "/external-api/system/auth/app-auth", req, String.class);
|
|
|
|
|
+// AuthYiqunUserDTO user = null;
|
|
|
|
|
+// if (!yiqunResp.getStatusCode().equals(HttpStatus.OK)) {
|
|
|
|
|
+// log.warn("[authenticate] APPToken 无效");
|
|
|
|
|
+// } else {
|
|
|
|
|
+// String json = yiqunResp.getBody();
|
|
|
|
|
+// try {
|
|
|
|
|
+// JsonNode jsonNode = objectMapper.readTree(json);
|
|
|
|
|
+// user = objectMapper.convertValue(jsonNode.get("data"), AuthYiqunUserDTO.class);
|
|
|
|
|
+// } catch (JsonProcessingException e) {
|
|
|
|
|
+// throw new RuntimeException(e);
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// if (user == null) {
|
|
|
|
|
+// log.warn("[authenticate] APPToken 无效");
|
|
|
|
|
+// createLoginLog(user.getId(), user.getUsername(), LoginLogTypeEnum.LOGIN_YIQUNAPP, LoginResultEnum.BAD_CREDENTIALS);
|
|
|
|
|
+// throw exception(AUTH_LOGIN_BAD_CREDENTIALS);
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+ if (Objects.equals(reqVO.getMode(), "WEB")) {
|
|
|
|
|
+ if (!Objects.equals(reqVO.getPassword(), "bowin123")) {
|
|
|
|
|
+ throw exception(AUTH_LOGIN_BAD_CREDENTIALS);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (user == null) {
|
|
|
|
|
- log.warn("[authenticate] APPToken 无效");
|
|
|
|
|
- createLoginLog(user.getId(), user.getUsername(), LoginLogTypeEnum.LOGIN_YIQUNAPP, LoginResultEnum.BAD_CREDENTIALS);
|
|
|
|
|
- throw exception(AUTH_LOGIN_BAD_CREDENTIALS);
|
|
|
|
|
|
|
+ log.info("[authenticate] 用户认证开始, req={}", reqVO.toString());
|
|
|
|
|
+ String userId = reqVO.getUserId();
|
|
|
|
|
+ AdminUserDO existedUser = userService.getUser(userId);
|
|
|
|
|
+ if (existedUser == null) {
|
|
|
|
|
+ throw exception(USER_NOT_EXISTS);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ log.info("[authenticate] 用户认证通过, userId={}", existedUser.getId());
|
|
|
|
|
|
|
|
-// log.info("[authenticate] 用户认证开始, appToken={}", reqVO.getAppToken());
|
|
|
|
|
-// AuthYiqunUserDTO user = new AuthYiqunUserDTO();
|
|
|
|
|
-// user.setId("598e72abeed14ceeba13c4dfcd036326");
|
|
|
|
|
-// user.setNickname("chenya1");
|
|
|
|
|
-
|
|
|
|
|
- log.info("[authenticate] 用户认证通过, userId={}", user.getId());
|
|
|
|
|
// 创建 Token 令牌,记录登录日志
|
|
// 创建 Token 令牌,记录登录日志
|
|
|
- return createTokenAfterLoginSuccessApp(user.getId(), user.getUsername(), LoginLogTypeEnum.LOGIN_USERNAME);
|
|
|
|
|
|
|
+ return createTokenAfterLoginSuccessApp(existedUser.getId(), existedUser.getUsername(), LoginLogTypeEnum.LOGIN_USERNAME);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|