| | |
| | | import com.ruoyi.common.core.constant.CacheConstants; |
| | | import com.ruoyi.common.core.constant.Constants; |
| | | import com.ruoyi.common.core.utils.IdUtils; |
| | | import com.ruoyi.common.core.utils.SecurityUtils; |
| | | import com.ruoyi.common.core.utils.ServletUtils; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.utils.ip.IpUtils; |
| | |
| | | public LoginUser getLoginUser(HttpServletRequest request) |
| | | { |
| | | // 获取请求携带的令牌 |
| | | String token = getToken(request); |
| | | String token = SecurityUtils.getToken(request); |
| | | return getLoginUser(token); |
| | | } |
| | | |
| | | /** |
| | | * 获取用户身份信息 |
| | | * |
| | | * @return 用户信息 |
| | | */ |
| | | public LoginUser getLoginUser(String token) |
| | | { |
| | | if (StringUtils.isNotEmpty(token)) |
| | | { |
| | | String userKey = getTokenKey(token); |
| | |
| | | private String getTokenKey(String token) |
| | | { |
| | | return ACCESS_TOKEN + token; |
| | | } |
| | | |
| | | /** |
| | | * 获取请求token |
| | | */ |
| | | private String getToken(HttpServletRequest request) |
| | | { |
| | | String token = request.getHeader(CacheConstants.HEADER); |
| | | if (StringUtils.isNotEmpty(token) && token.startsWith(CacheConstants.TOKEN_PREFIX)) |
| | | { |
| | | token = token.replace(CacheConstants.TOKEN_PREFIX, ""); |
| | | } |
| | | return token; |
| | | } |
| | | } |