Commit 7dc47c16 authored by liuyang's avatar liuyang

fixed auth faild code

parent 41d9479d
...@@ -3,23 +3,23 @@ package com.qkdata.common.oauth; ...@@ -3,23 +3,23 @@ package com.qkdata.common.oauth;
public enum AuthorizationResponseEnum{ public enum AuthorizationResponseEnum{
MISSING_TOKEN("403", "HEADER中不存在TOKEN"), MISSING_TOKEN(403, "HEADER中不存在TOKEN"),
INVALID_TOKEN("403", "校验TOKEN失败"), INVALID_TOKEN(403, "校验TOKEN失败"),
EXPIRED_TOKEN("403", "TOKEN已过期"), EXPIRED_TOKEN(403, "TOKEN已过期"),
MISSING_CLAIMS("403", "不合法的TOKEN, 信息可能被篡改"), MISSING_CLAIMS(403, "不合法的TOKEN, 信息可能被篡改"),
INVALID_CLAIM("403", "不合法的TOKEN, 系统中不存在资源"); INVALID_CLAIM(403, "不合法的TOKEN, 系统中不存在资源");
private String value; private Integer code;
private String text; private String text;
AuthorizationResponseEnum(String value, String text) { AuthorizationResponseEnum(Integer code, String text) {
this.value = value; this.code = code;
this.text = text; this.text = text;
} }
public String value() { public Integer code() {
return this.value; return this.code;
} }
public String text() { public String text() {
......
...@@ -52,7 +52,7 @@ public class OAuthFilter extends AuthenticatingFilter { ...@@ -52,7 +52,7 @@ public class OAuthFilter extends AuthenticatingFilter {
httpResponse.setHeader("Access-Control-Allow-Credentials", "true"); httpResponse.setHeader("Access-Control-Allow-Credentials", "true");
httpResponse.setHeader("Access-Control-Allow-Origin", HttpContextUtils.getOrigin()); httpResponse.setHeader("Access-Control-Allow-Origin", HttpContextUtils.getOrigin());
Result responseData = Result.failed(AuthorizationResponseEnum.MISSING_TOKEN.text()); Result responseData = Result.of("",AuthorizationResponseEnum.MISSING_TOKEN.code(),AuthorizationResponseEnum.MISSING_TOKEN.text());
String json = mapper.writeValueAsString(responseData); String json = mapper.writeValueAsString(responseData);
httpResponse.getWriter().print(json); httpResponse.getWriter().print(json);
...@@ -72,7 +72,7 @@ public class OAuthFilter extends AuthenticatingFilter { ...@@ -72,7 +72,7 @@ public class OAuthFilter extends AuthenticatingFilter {
try { try {
//处理登录失败的异常 //处理登录失败的异常
Throwable throwable = e.getCause() == null ? e : e.getCause(); Throwable throwable = e.getCause() == null ? e : e.getCause();
Result rd = Result.failed(AuthorizationResponseEnum.INVALID_TOKEN.value(),e.getMessage()); Result rd = Result.of("",AuthorizationResponseEnum.MISSING_TOKEN.code(),e.getMessage());
String json = mapper.writeValueAsString(rd); String json = mapper.writeValueAsString(rd);
httpResponse.getWriter().print(json); httpResponse.getWriter().print(json);
} catch (IOException e1) { } catch (IOException e1) {
......
...@@ -81,7 +81,7 @@ public class OAuthRealm extends AuthorizingRealm { ...@@ -81,7 +81,7 @@ public class OAuthRealm extends AuthorizingRealm {
throw new AuthenticationException(AuthorizationResponseEnum.INVALID_CLAIM.text()); throw new AuthenticationException(AuthorizationResponseEnum.INVALID_CLAIM.text());
} }
if (user.getStatus() == AccountStatusEnum.DISABLE){ if (user.getStatus() == AccountStatusEnum.DISABLE){
throw new AuthenticationException("您已退出团队,不能登陆"); throw new AuthenticationException("您的帐号已被禁用");
} }
SimpleAuthenticationInfo info = new SimpleAuthenticationInfo(user, accessToken, getName()); SimpleAuthenticationInfo info = new SimpleAuthenticationInfo(user, accessToken, getName());
return info; return info;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment