| | |
| | | if (admin == null) { |
| | | return ResponseUtil.error(ResponseStatusEnums.BAD_CREDENTIALS.getCode(), ResponseStatusEnums.BAD_CREDENTIALS.getMessage()); |
| | | } |
| | | // String s = RedisUtils.getBean().get(loginParam.getKey()); |
| | | // if (!loginParam.getVlue().equals(s)) { |
| | | // log.error(loginParam.getVlue() + "验证码"); |
| | | // return ResponseUtil.error(ResponseStatusEnums.BAD_AUTHENTICATION.getCode(), ResponseStatusEnums.BAD_AUTHENTICATION.getMessage()); |
| | | // } |
| | | // RedisUtils.getBean().delete(loginParam.getKey()); |
| | | String s = RedisUtils.getBean().get(loginParam.getKey()); |
| | | if (!loginParam.getVlue().equals(s)) { |
| | | log.error(loginParam.getVlue() + "验证码"); |
| | | return ResponseUtil.error(ResponseStatusEnums.BAD_AUTHENTICATION.getCode(), ResponseStatusEnums.BAD_AUTHENTICATION.getMessage()); |
| | | } |
| | | RedisUtils.getBean().delete(loginParam.getKey()); |
| | | if (!passwordEncoder.matches(loginParam.getPassword(), admin.getPassword())) { |
| | | return ResponseUtil.error(ResponseStatusEnums.BAD_CREDENTIALS.getCode(), ResponseStatusEnums.BAD_CREDENTIALS.getMessage()); |
| | | } |
| | |
| | | put("token", properties.getTokenStartWith() + token); |
| | | put("user", admin); |
| | | }}; |
| | | //保存登录信息到日志 |
| | | |
| | | |
| | | /** |
| | | * 登录信息日志记录开始 |
| | | */ |
| | | UserAgent userAgent = UserAgent.parseUserAgentString(request.getHeader("User-Agent")); |
| | | Browser browser = userAgent.getBrowser(); |
| | | OperatingSystem os = userAgent.getOperatingSystem(); |
| | | String content = "登录IP地址:" + IPUtils.getPublicIp() + ",操作系统:" + os + ",浏览器:" + browser; |
| | | |
| | | StoreOperationRecordsUtils.storeOperationData(null, null, "用户登录", content, null); |
| | | String content = "用户ID:" + admin.getId() |
| | | + ",用户名:" + admin.getUsername() |
| | | + ",用户类型:管理员" |
| | | + ",登录IP地址:" + IPUtils.getPublicIp() |
| | | + ",操作系统:" + os |
| | | + ",浏览器:" + browser; |
| | | StoreOperationRecordsUtils.storeOperationData(null, null, "用户登录", content); |
| | | /** |
| | | * 登录信息日志记录结束 |
| | | */ |
| | | return ResponseUtil.success(authInfo); |
| | | } |
| | | |
| | |
| | | |
| | | @GetMapping(value = "/logout") |
| | | public ResponseVO<Object> LogOut() { |
| | | String content = "用户名:" + SecurityUtils.getUsername(); |
| | | StoreOperationRecordsUtils.storeOperationData(null, null, "用户退出登录", content); |
| | | String key = String.format("%d_%d", SecurityUtils.getUserDetails().getUserId(), SecurityUtils.getUserDetails().getAdministratorType()); |
| | | redisService.set(key, null); |
| | | return ResponseUtil.success("退出登录成功"); |