| | |
| | | package com.ruoyi.common.core.utils; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; |
| | | import com.ruoyi.common.core.constant.CacheConstants; |
| | | import com.ruoyi.common.core.text.Convert; |
| | |
| | | */ |
| | | public static String getUsername() |
| | | { |
| | | return ServletUtils.getRequest().getHeader(CacheConstants.DETAILS_USERNAME); |
| | | String username = ServletUtils.getRequest().getHeader(CacheConstants.DETAILS_USERNAME); |
| | | return ServletUtils.urlDecode(username); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取请求token |
| | | */ |
| | | public static String getToken() |
| | | { |
| | | return getToken(ServletUtils.getRequest()); |
| | | } |
| | | |
| | | /** |
| | | * 根据request获取请求token |
| | | */ |
| | | public static String getToken(HttpServletRequest request) |
| | | { |
| | | String token = ServletUtils.getRequest().getHeader(CacheConstants.HEADER); |
| | | if (StringUtils.isNotEmpty(token) && token.startsWith(CacheConstants.TOKEN_PREFIX)) |
| | | { |
| | | token = token.replace(CacheConstants.TOKEN_PREFIX, ""); |
| | | } |
| | | return token; |
| | | } |
| | | |
| | | /** |
| | | * 是否为管理员 |
| | | * |
| | | * @param userId 用户ID |