title: Manage User Redirect Spring Security
body: <p>i'm new to spring security can any one guide me how to do this. my configuration class of spring security is mention below: i made my home page "/" visible to all user. so i didn't use "/" in http.antmatchs("/") in home page my nav bar has link for "login and signup". after successful login user redirect to "buyer/list" endpoint  which i mention in configuration. <strong>what i want is "login user" can't visit homepage again.</strong> for this i also use </p>
  
  <pre><code>Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
  </code></pre>
  
  <p>for "/" mapping controller, but it throw nullPointerException. can any one guide me how do i proceed. if there is other approach please mention.</p>
  
  <pre><code>Configuration
  @EnableWebSecurity
  public class SecureConfig extends WebSecurityConfigurerAdapter {
  
      @Autowired
      UserDetailsService userDetailsService;
  
      @Value("${winni.auth.exit}")
      private String authExit;
  
      @Override
      protected void configure(AuthenticationManagerBuilder auth) throws Exception {
          auth.userDetailsService(userDetailsService)
                  .passwordEncoder(passwordEncoder());
      }
  
      @Override
      protected void configure(HttpSecurity http) throws Exception {
  
          http.requestMatchers()
                  .antMatchers("/login", "/web/**", "/action/**", "/cart/**", "/cart/xhr/**", "/buyer/**","/profile/**","/chat/**","/order/**")
                  .and()
                  .authorizeRequests()
                  .anyRequest().authenticated()
                  .and()
                  .formLogin().loginPage("/login").defaultSuccessUrl("/buyer/list", true).permitAll().and()
                  .logout().logoutSuccessUrl(authExit);
      }
  
      @Bean
      public PasswordEncoder passwordEncoder() {
          return new BCryptPasswordEncoder();
      }
  
      @Override
      public void configure(WebSecurity web) throws Exception {
          web.ignoring().antMatchers("/assets/**");
      }
  
  }
  </code></pre>