What is the correct way to get the logged user via spring security (angularjs)
<p>After success login, how I can retrieve the logged users in spring <code>RestController</code>?</p>

<p>I use the below method/principle to get the logged user, but it retrieves anonymousUser instead of logged user.</p>

<pre><code>Principal principal = SecurityContextHolder.getContext().getAuthentication();
</code></pre>

<p>or</p>

<pre><code>Authentication auth = SecurityContextHolder.getContext().getAuthentication();
</code></pre>