title: Do I need a separate JWT Filter for Multiple Logins?
body: <p>The User login is working well but I want to add a Customer Module to the project. I know that I need to write a custom UserDetails class to get the customer Username but I want to ask if I need to write another Custom JWT filter for the Customer Login validation. Presently this is the Filter class that I have for User Login. I have added a username and password field to the Customer entity.</p>
  <pre><code>
  @Component
  public class JwtRequestFilter extends OncePerRequestFilter {
  
      
  
      @Autowired
      private JwtTokenUtil jwtTokenUtil;
      
      @Autowired
      private UserAccountService myUserDetailsService;
      
      
      @Override
      protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
              throws ServletException, IOException {
  
          final String requestTokenHeader = request.getHeader(&quot;Authorization&quot;);
  
          String username = null;
          String jwtToken = null;
          
          if (requestTokenHeader != null) {
              jwtToken = requestTokenHeader.substring(7);
              try {
                  username = jwtTokenUtil.getUsernameFromToken(jwtToken);
              } catch (IllegalArgumentException e) {
                  System.out.println(&quot;Unable to get JWT Token&quot;);
              } catch (ExpiredJwtException e) {
                  System.out.println(&quot;JWT Token has expired&quot;);
              }
          } 
  
          
          if (username != null &amp;&amp; SecurityContextHolder.getContext().getAuthentication() == null) {
        
              UserDetails userDetails = this.myUserDetailsService.loadUserByUsername(username);
          if (jwtTokenUtil.validateToken(jwtToken, userDetails)) {
              
              UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken = new UsernamePasswordAuthenticationToken(
                          userDetails, null, userDetails.getAuthorities());
                  
              String authorities = userDetails.getAuthorities().stream().map(GrantedAuthority::getAuthority)
                      .collect(Collectors.joining());
               System.out.println(&quot;Authorities granted : &quot; + authorities);
                      
                  usernamePasswordAuthenticationToken
                          .setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
                  
                  SecurityContextHolder.getContext().setAuthentication(usernamePasswordAuthenticationToken);
              }
              else {
                  System.out.println(&quot;Not Valid Token&quot;);
              }
  
          }
          chain.doFilter(request, response);
      }
  
  
  }
  
  
  </code></pre>
  <p>As you can see the Filter is using the custom UserDetails to verify the username . How do I add the Customer userdetails service to the filter ? This is my first multiple login project please be  lenient with me.</p>