title: Grails Spring Security Sign up / Register User
body: <p>I've installed Spring Security plugin to my Grails application, saw login which works fine, but when I wanted to create Registration for users and authenticate the user after the registration, manually in the code, I couldn't. </p>
  
  <p>Is there any solution to that? How can it be that Spring Security does not allow simple using pushing of authenticated users to the session or Spring Security Context.
  Here is what I tried:</p>
  
  <pre><code>UsernamePasswordAuthenticationToken uat = new UsernamePasswordAuthenticationToken(user.email, user.password, null); 
  uat.setDetails(user);
  SecurityContext context = SecurityContextHolder.getContext();
  context.setAuthentication(uat);
  </code></pre>
  
  <p>This authenticates the user, but I couldn't get him with the next code:</p>
  
  <pre><code>springSecurityService.currentUser
  </code></pre>
  
  <p>Only with this:</p>
  
  <pre><code>SecurityContextHolder.getContext().getAuthentication().getPrincipal();
  </code></pre>
  
  <p>I am confused now, what is the right way to use Spring Security.</p>
  
  <p>I started to build now my own UserDetailsService, but I confused and don't know what are the next steps if I want to create my own Authentication method?</p>