the stream is a bit outdated, but for JWTToken users this does not work, as tokens are not saved. Therefore, another option is to use a filter. 1 create a method for the administrator to lock / unlock the user in your database. 2 use a filter, and if the method needs authentication, if the user is active or not
Example:
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); if(authentication != null && authentication.getName() != null && !authentication.getName().equalsIgnoreCase("anonymousUser")) { UserModel user = userService.getUser(authentication.getName()); if(user != null && !user.isActivated()) throw new SecurityException("SECURITY_USER_DISABLED"); } chain.doFilter(request, response); }
On the client side, just catch this error and disconnect the user, hope this helps someone.
mcfly
source share