Fix route login but no token

This commit is contained in:
jeffcheasey88 2023-04-22 08:51:08 +02:00
parent 209aa5b6ce
commit c4de049e58

View file

@ -62,7 +62,10 @@ public class Router{
for(Entry<Response, Route> routes : this.responses.get(type).entrySet()){
Matcher matcher = this.patterns.get(routes.getKey()).matcher(path);
if(matcher.matches()){
if(user == null && routes.getValue().needLogin()) return;
if(user == null && routes.getValue().needLogin()){
HttpUtil.responseHeaders(writer, 401, "Access-Control-Allow-Origin: *");
return;
}
if(routes.getValue().websocket()){
HttpUtil.switchToWebSocket(reader, writer);
reader = new WebSocketReader(reader);