| | |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import com.zy.asrs.wcs.common.config.ConfigProperties; |
| | | import com.zy.asrs.wcs.common.constant.Constants; |
| | | import com.zy.asrs.wcs.sys.entity.Menu; |
| | | import com.zy.asrs.wcs.sys.entity.User; |
| | | import com.zy.asrs.wcs.sys.entity.UserLogin; |
| | | import com.zy.asrs.wcs.sys.service.UserLoginService; |
| | | import com.zy.asrs.wcs.sys.service.UserService; |
| | | import com.zy.asrs.wcs.system.entity.Menu; |
| | | import com.zy.asrs.wcs.system.entity.User; |
| | | import com.zy.asrs.wcs.system.entity.UserLogin; |
| | | import com.zy.asrs.wcs.system.service.UserLoginService; |
| | | import com.zy.asrs.wcs.system.service.UserService; |
| | | import com.zy.asrs.wcs.utils.HttpUtils; |
| | | import com.zy.asrs.wcs.utils.JwtUtil; |
| | | import io.jsonwebtoken.Claims; |
| | |
| | | User user; |
| | | // 白名单 |
| | | if (WHITE_LIST.contains(access_token)) { |
| | | user = userService.getByUsername("openapi", null); |
| | | user = userService.getByUsername("root", 1L); |
| | | if (user == null) { |
| | | throw new UsernameNotFoundException("Username not found"); |
| | | } |
| | |
| | | String token = JwtUtil.buildToken(jwtSubject, configProperties.getTokenExpireTime(), |
| | | configProperties.getTokenKey()); |
| | | response.addHeader(Constants.TOKEN_HEADER_NAME, token); |
| | | userLoginService.saveAsync(user.getId(), UserLogin.TYPE_REFRESH, null, user.getHostId(), request); |
| | | userLoginService.saveAsync(user.getId(), token, UserLogin.TYPE_REFRESH, user.getHostId(), null, request); |
| | | } |
| | | } |
| | | } catch (ExpiredJwtException e) { |
| | | // e.printStackTrace(); |
| | | HttpUtils.responseError(response, Constants.TOKEN_EXPIRED_CODE, Constants.TOKEN_EXPIRED_MSG, |
| | | e.getMessage()); |
| | | return; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | HttpUtils.responseError(response, Constants.BAD_CREDENTIALS_CODE, Constants.BAD_CREDENTIALS_MSG, |
| | | e.toString()); |
| | | return; |