RegisterService does not add session into ICacheClient. Why?


I have a question about the code for RegisterService. I’ve been debugging through the code and I don’t quite understand why RegisterService creates a session but never persists it into ICacheClient. I see that cookies are set with ss-pid and ss-id but the server side doesn’t seem to persist it. I guess this means that a /auth/* call is necessary after /register but in that case doesn’t it mean the cookies set by /register are not helpful? I’m just trying to learn a little bit about the code; please excuse my ignorance! :slight_smile:

Thank you!

I did look at the SocialBootstrap app and it does appear that you register first and then auth. The pattern seems a bit unusual but I guess it works. I guess you could always call auth immediately after register.

If you want to authenticate at registration in the same call set AutoLogin param, e.g:

new Register {
    AutoLogin = true

Ah yes. I see it now. When AutoLogin is set the Register Service posts to the auth/credentials endpoint which will save the session. Not sure how I could have missed that! Thanks!

if (request.AutoLogin.GetValueOrDefault())
            using (var authService = base.ResolveService<AuthenticateService>())
                var authResponse = authService.Post(
                    new Authenticate {
                        provider = CredentialsAuthProvider.Name,
                        UserName = request.UserName ?? request.Email,
                        Password = request.Password,
                        Continue = request.Continue
1 Like