| | |
| | | import org.springblade.core.secure.BladeUser; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tenant.annotation.NonDS; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.support.Kv; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | |
| | | |
| | | private final BladeRedis bladeRedis; |
| | | private final JwtProperties jwtProperties; |
| | | |
| | | @ApiLog("根据token获取登录用户") |
| | | @GetMapping("/getuser/token") |
| | | public R<Object> getUserLoginInfoByToken() { |
| | | String token = JwtUtil.getToken(WebUtil.getRequest().getHeader(TokenConstant.HEADER)); |
| | | return R.data(bladeRedis.get(token)); |
| | | } |
| | | |
| | | @ApiLog("登录用户验证") |
| | | @PostMapping("/oauth/token") |
| | |
| | | Kv authInfo1 = TokenUtil.createAuthInfo(userInfo); |
| | | String access_token = authInfo1.get("access_token").toString(); |
| | | // 存入redis并设置过期时间为60分钟 |
| | | bladeRedis.setEx(access_token, access_token, Duration.ofMinutes(60)); |
| | | bladeRedis.setEx(access_token, authInfo1, Duration.ofMinutes(60)); |
| | | return TokenUtil.createAuthInfo(userInfo); |
| | | } |
| | | |