mirror of
https://github.com/luoye663/e5.git
synced 2024-12-26 03:38:53 +00:00
如果是OPTIONS则结束请求
This commit is contained in:
parent
de9c974bbf
commit
9f49dbf8ec
@ -41,7 +41,7 @@ public class UsernamePasswordAuthenticationToken extends AbstractAuthenticationT
|
|||||||
super(null);
|
super(null);
|
||||||
this.code = code;
|
this.code = code;
|
||||||
super.setAuthenticated(false);
|
super.setAuthenticated(false);
|
||||||
logger.info("MobileLoginAuthenticationToken setAuthenticated ->false loading ...");
|
logger.info("创建未认证的用户名密码认证对象1 setAuthenticated ->false loading ...");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建未认证的用户名密码认证对象
|
// 创建未认证的用户名密码认证对象
|
||||||
@ -50,7 +50,7 @@ public class UsernamePasswordAuthenticationToken extends AbstractAuthenticationT
|
|||||||
this.code = code;
|
this.code = code;
|
||||||
this.state = state;
|
this.state = state;
|
||||||
super.setAuthenticated(false);
|
super.setAuthenticated(false);
|
||||||
logger.info("MobileLoginAuthenticationToken setAuthenticated ->false loading ...");
|
logger.info("创建未认证的用户名密码认证对象2 setAuthenticated ->false loading ...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,6 +7,8 @@ import com.google.gson.JsonParser;
|
|||||||
import io.qyi.e5.config.security.UsernamePasswordAuthenticationToken;
|
import io.qyi.e5.config.security.UsernamePasswordAuthenticationToken;
|
||||||
import io.qyi.e5.util.SpringUtil;
|
import io.qyi.e5.util.SpringUtil;
|
||||||
import io.qyi.e5.util.redis.RedisUtil;
|
import io.qyi.e5.util.redis.RedisUtil;
|
||||||
|
import org.springframework.http.HttpMethod;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.security.core.authority.AuthorityUtils;
|
import org.springframework.security.core.authority.AuthorityUtils;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
import org.springframework.web.filter.OncePerRequestFilter;
|
import org.springframework.web.filter.OncePerRequestFilter;
|
||||||
@ -50,10 +52,16 @@ public class LinkTokenAuthenticationFilter extends OncePerRequestFilter {
|
|||||||
HttpServletResponse response = httpServletResponse;
|
HttpServletResponse response = httpServletResponse;
|
||||||
response.setHeader("Access-Control-Allow-Origin","*");
|
response.setHeader("Access-Control-Allow-Origin","*");
|
||||||
response.setHeader("Access-Control-Allow-Credentials", "true");
|
response.setHeader("Access-Control-Allow-Credentials", "true");
|
||||||
response.setHeader("Access-Control-Allow-Methods", "POST, GET, PATCH, DELETE, PUT");
|
response.setHeader("Access-Control-Allow-Methods", "\"GET, HEAD, POST");
|
||||||
response.setHeader("Access-Control-Max-Age", "3600");
|
response.setHeader("Access-Control-Max-Age", "3600");
|
||||||
response.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
|
response.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, token");
|
||||||
filterChain.doFilter(httpServletRequest, httpServletResponse);
|
/*如果是OPTIONS则结束请求*/
|
||||||
|
if (HttpMethod.OPTIONS.toString().equals(httpServletRequest.getMethod())) {
|
||||||
|
response.setStatus(HttpStatus.NO_CONTENT.value());
|
||||||
|
} else {
|
||||||
|
filterChain.doFilter(httpServletRequest, response);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendJson(HttpServletResponse httpServletResponse, Object o) throws IOException {
|
public void sendJson(HttpServletResponse httpServletResponse, Object o) throws IOException {
|
||||||
|
Loading…
Reference in New Issue
Block a user