Auto login after registration
Is it possible with Identity Server 4 to have auto login after registration of a new user (for a SPA)?
We will support that, but everything around that is still a work in progress.
aaaaaaaaah good to know ;)
Thanks!
Just know that you will probably skip any email verification in the process of doing that. It really depends on your setup, but you can implement a UserService on identityserver to register users for you. I'm not sure if its present in the current samples, but you could built it yourself. Second option have identityserver just authorize and issue tokens, and your api do the actual user registration with a Resource Owner type setup.
So you could potentially do this (if you have a resource owner setup):
- In your register() function on the SPA do a POST
/api/registerwhich returns userId/true if successful. Your api/register function will have[AllowAnonymous]attribute (or no[Authorize]attribute. Just make sure your API is closed off with CORS. - Then in same call, request token from IdentityServer with username and password used in previous step:
/connect/token(You will need someUserServicesetup on your IdentityServer, theres an example on one of the questions in this repo). IdentityServer issues token save that in your SPA (cookies, local/session storage). - Log the user into your SPA by checking if the token is valid or get user info. Use the token with headers
Authentication: Bearer <token>and call the API as you wish.
Maybe the identityserver security masters can comment on this if there are any big security flaws in my design, as I would like to know as well :)
And also how to fix the security holes of course!!!
I hope this helps.
I thought UserService was gone in version 4?
everything around that is still a work in progress
:)
Ah that too ;)
Ok I'll wait :D
Hi guys, i see this issue is now closed. is there per-chance a sample on how to implement this. Thanks :)
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.