Skip to content

Commit

Permalink
Disable authorization for options methods
Browse files Browse the repository at this point in the history
  • Loading branch information
krabiworld committed Jan 5, 2025
1 parent e635bad commit d3167e8
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import su.foxogram.constants.AttributesConstants;
Expand All @@ -14,6 +15,7 @@
import su.foxogram.models.User;
import su.foxogram.services.AuthenticationService;

import java.util.Objects;
import java.util.Set;

@Slf4j
Expand All @@ -34,6 +36,8 @@ public AuthenticationInterceptor(AuthenticationService authenticationService) {

@Override
public boolean preHandle(HttpServletRequest request, @NotNull HttpServletResponse response, @NotNull Object handler) throws UserUnauthorizedException, UserEmailNotVerifiedException {
if (Objects.equals(request.getMethod(), HttpMethod.OPTIONS.name())) return true;

String requestURI = request.getRequestURI();
boolean ignoreEmailVerification = EMAIL_VERIFICATION_IGNORE_PATHS.stream().anyMatch(requestURI::contains);

Expand Down

0 comments on commit d3167e8

Please sign in to comment.