Commit 7dc47c16 authored by liuyang's avatar liuyang

fixed auth faild code

parent 41d9479d
......@@ -3,23 +3,23 @@ package com.qkdata.common.oauth;
public enum AuthorizationResponseEnum{
MISSING_TOKEN("403", "HEADER中不存在TOKEN"),
INVALID_TOKEN("403", "校验TOKEN失败"),
EXPIRED_TOKEN("403", "TOKEN已过期"),
MISSING_CLAIMS("403", "不合法的TOKEN, 信息可能被篡改"),
INVALID_CLAIM("403", "不合法的TOKEN, 系统中不存在资源");
MISSING_TOKEN(403, "HEADER中不存在TOKEN"),
INVALID_TOKEN(403, "校验TOKEN失败"),
EXPIRED_TOKEN(403, "TOKEN已过期"),
MISSING_CLAIMS(403, "不合法的TOKEN, 信息可能被篡改"),
INVALID_CLAIM(403, "不合法的TOKEN, 系统中不存在资源");
private String value;
private Integer code;
private String text;
AuthorizationResponseEnum(String value, String text) {
this.value = value;
AuthorizationResponseEnum(Integer code, String text) {
this.code = code;
this.text = text;
}
public String value() {
return this.value;
public Integer code() {
return this.code;
}
public String text() {
......
......@@ -52,7 +52,7 @@ public class OAuthFilter extends AuthenticatingFilter {
httpResponse.setHeader("Access-Control-Allow-Credentials", "true");
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);
httpResponse.getWriter().print(json);
......@@ -72,7 +72,7 @@ public class OAuthFilter extends AuthenticatingFilter {
try {
//处理登录失败的异常
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);
httpResponse.getWriter().print(json);
} catch (IOException e1) {
......
......@@ -81,7 +81,7 @@ public class OAuthRealm extends AuthorizingRealm {
throw new AuthenticationException(AuthorizationResponseEnum.INVALID_CLAIM.text());
}
if (user.getStatus() == AccountStatusEnum.DISABLE){
throw new AuthenticationException("您已退出团队,不能登陆");
throw new AuthenticationException("您的帐号已被禁用");
}
SimpleAuthenticationInfo info = new SimpleAuthenticationInfo(user, accessToken, getName());
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