How to redirect to the homepage if the user accesses the login page after being logged in?

后端 未结 6 1365
一生所求
一生所求 2020-11-28 13:16

Here is my spring security config:




        
6条回答
  •  情书的邮戳
    2020-11-28 14:12

    You can try checking

    if(SecurityContextHolder.getContext().getAuthentication() == null)
    

    True means the user isn't authenticated, and thus can be sent to the login page. I don't know how robust/reliable this is, but it seems reasonable to try.

提交回复
热议问题