Class RoleUpdateInterceptor
java.lang.Object
edu.ucsb.cs156.frontiers.interceptors.RoleUpdateInterceptor
- All Implemented Interfaces:
org.springframework.web.servlet.HandlerInterceptor
@Component
public class RoleUpdateInterceptor
extends Object
implements org.springframework.web.servlet.HandlerInterceptor
RoleUpdateInterceptor reloads a user's security context on each request to the backend. This is
necessary to ensure that the user has the correct roles and does not have to log in or out to
have access to restricted endpoints.
To prevent interference with @WebMvcTest test slices, ControllerTestCase contains a passthrough RoleUpdateInterceptor MockitoBean so that every ControllerTestCase is not required to add an AdminRepository and InstructorRepository MockitoBean.
-
Constructor Summary
ConstructorsConstructorDescriptionRoleUpdateInterceptor
(AdminRepository adminRepository, InstructorRepository instructorRepository) -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.web.servlet.HandlerInterceptor
afterCompletion, postHandle
-
Constructor Details
-
RoleUpdateInterceptor
public RoleUpdateInterceptor(AdminRepository adminRepository, InstructorRepository instructorRepository)
-
-
Method Details
-
preHandle
public boolean preHandle(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Object handler) - Specified by:
preHandle
in interfaceorg.springframework.web.servlet.HandlerInterceptor
-