Skip to content

Commit

Permalink
fix: return the proper response for failed OAUTH request
Browse files Browse the repository at this point in the history
  • Loading branch information
PenghaiZhang committed Sep 29, 2023
1 parent 873f4ea commit 08dde47
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.tle.web.core.filter.UserStateResult.Result;
import com.tle.web.dispatcher.AbstractWebFilter;
import com.tle.web.dispatcher.FilterResult;
import java.io.IOException;
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.servlet.http.HttpServletRequest;
Expand All @@ -57,7 +58,8 @@ public class TleSessionFilter extends AbstractWebFilter {
private PluginTracker<UserStateHook> userStateHooks;

@Override
public FilterResult filterRequest(HttpServletRequest request, HttpServletResponse response) {
public FilterResult filterRequest(HttpServletRequest request, HttpServletResponse response)
throws IOException {
final FilterResult result =
new FilterResult(
(request1, response1) -> {
Expand Down Expand Up @@ -99,7 +101,11 @@ public FilterResult filterRequest(HttpServletRequest request, HttpServletRespons
}
} catch (RuntimeException t) {
userService.logoutToGuest(userService.getWebAuthenticationDetails(request), false);
throw t;
if (t instanceof WebException) {
response.sendError(((WebException) t).getCode());
} else {
throw t;
}
}

return result;
Expand Down

0 comments on commit 08dde47

Please sign in to comment.