title: Automatically login local user after registration with IdentityServer3
body: <p>Using <a href="https://github.com/IdentityServer/IdentityServer3">IdentityServer3</a> I need to automatically login and redirect a local user back to the client application after the user has completed a registration process. Is there an elegant way to do this? From my digging I suspect not, in which case is there a hack I can use to achieve this?</p>
  
  <p>I was able to achieve this for external users using a custom <a href="https://identityserver.github.io/Documentation/docs/advanced/userService.html">User Service</a>, but this utilized a partial login. However, for local users they aren't in the authentication process handled by the User Service until they login with a username and password.</p>
  
  <p>Please also note that I don't have access to the users password as the registration process is covered by multiple screens / views as in this instance they are required to verify their email as part of the registration process.</p>
  
  <p><strong>Progress:</strong></p>
  
  <p>I've found this <a href="https://github.com/IdentityServer/IdentityServer3/issues/563">https://github.com/IdentityServer/IdentityServer3/issues/563</a> but haven't worked out how to trigger the redirect.</p>
  
  <p>I'm attempting to issue an authentication token using:</p>
  
  <pre><code>var localAuthResult = userService.AuthenticateLocalAsync(user);
  Request.GetOwinContext().Authentication.SignIn(new ClaimsIdentity(localAuthResult.Result.User.Claims, Thinktecture.IdentityServer.Core.Constants.PrimaryAuthenticationType));
  </code></pre>
  
  <p>But the best I can do so far is redirect the user back to the login screen:</p>
  
  <pre><code>HttpCookie cookie = Request.Cookies["signin"]; // Stored previously at beginning of registration process
  return Redirect("~/core/login?signin=" + cookie.Value);
  </code></pre>