|
@@ -31,24 +31,21 @@ public class AuthUtils {
|
|
|
|
|
|
public static ServletRequestAttributes getRequestAttributes() {
|
|
public static ServletRequestAttributes getRequestAttributes() {
|
|
RequestAttributes r = RequestContextHolder.currentRequestAttributes();
|
|
RequestAttributes r = RequestContextHolder.currentRequestAttributes();
|
|
- return (ServletRequestAttributes) r;
|
|
|
|
|
|
+ return (ServletRequestAttributes) r;
|
|
}
|
|
}
|
|
|
|
|
|
public static HttpServletRequest getRequest() {
|
|
public static HttpServletRequest getRequest() {
|
|
ServletRequestAttributes r = getRequestAttributes();
|
|
ServletRequestAttributes r = getRequestAttributes();
|
|
- return r == null ? null : r.getRequest();
|
|
|
|
|
|
+ return r.getRequest();
|
|
}
|
|
}
|
|
|
|
|
|
public static HttpServletResponse getResponse() {
|
|
public static HttpServletResponse getResponse() {
|
|
ServletRequestAttributes r = getRequestAttributes();
|
|
ServletRequestAttributes r = getRequestAttributes();
|
|
- return r == null ? null : r.getResponse();
|
|
|
|
|
|
+ return r.getResponse();
|
|
}
|
|
}
|
|
|
|
|
|
public static String getToken() {
|
|
public static String getToken() {
|
|
HttpServletRequest request = getRequest();
|
|
HttpServletRequest request = getRequest();
|
|
- if (request == null) {
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
return (String) request.getAttribute(AuthUtils.REQ_TOKEN);
|
|
return (String) request.getAttribute(AuthUtils.REQ_TOKEN);
|
|
}
|
|
}
|
|
public static Long getUserId() {
|
|
public static Long getUserId() {
|
|
@@ -61,9 +58,6 @@ public class AuthUtils {
|
|
|
|
|
|
public static AuthUser getUser() {
|
|
public static AuthUser getUser() {
|
|
HttpServletRequest request = getRequest();
|
|
HttpServletRequest request = getRequest();
|
|
- if (request == null) {
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
AuthUser user = null;
|
|
AuthUser user = null;
|
|
Object o = request.getAttribute(REQ_USER);
|
|
Object o = request.getAttribute(REQ_USER);
|
|
if (o != null) {
|
|
if (o != null) {
|