Developer Forum »
Session - System has no content associated
15 posts

Hey,

I have an error with login on a site, where the Session get's messed up after changing the password with "user.Password.GenerateAndSetNew();" and then sending it on sms with "WAFContext.Session.SendSms(msg, Mobile, "NAL");"

The error occurs when i try to use WAFContext.Session.GetUser() or any of the WAFRuntime sessions aswell. 

WAFContext.Session.IsAnonymous() always triggers as false, so the normal failchecks don't really work.

 

The UserID is -2 and Username is System.

The session is of type "System" which has no content-object associated with it.

 

 

The site in question is dev65.oxx.no 

 

Thanks in advance :)

181 posts

Hi!

I've been trying to recreate the error, but nothing fails in my tests. Just to make sure I test the same thing, this is what I've been trying:

1.) I added a login form to the Basic demo site.

2.) I set the "Read access" for one of the articles to System. 

3.) I added a button to reset the password, if the user is logged in.

4.) In the click event of the button, I have this code:

if (!WAFContext.Session.IsAnonymous() && WAFContext.Session.Access.IsStored) {
            SystemUser user = WAFContext.Engine.SystemSession.GetContent<SystemUser>(WAFContext.Session.UserId);
            string newPassword = user.Password.GenerateAndSetNew();
            user.UpdateChanges();
            litNewPw.Text = newPassword;
        }

 

It works well, with no error message. The username is still the same after having changed the password.  When I logout and try to login again, the new password works as expected.

Am I missing something?

15 posts

Hmm i'm not exactly sure, the only thing different is that the SystemUser is a custom type Participant, which user AutoLoginToken, which is just :

            string token = BaseCMUser.GenerateAutoLoginToken();

            this.AutoLoginToken = token;

            this.AutoLoginEndTime = DateTime.Now.AddHours(24);

            this.UpdateChanges(true, false);

            return token;

 

 

There's a lot of behind the scenes code going on in this site so it's difficult to narrow it down without posting entire classes, so i think the easiest is for you to see for yourself. If you go to dev65.oxx.no and try to login with : 40552878 / pnDM3zMN or create a password yourself. 

Thanks to : WAFContext.Session.Access.IsStored It doesn't crash when the error occurs, but it never manages to login either.  http://dev65.oxx.no/admin/main still crashes as "normal" when you're logged in

 

 

181 posts

Hi!

I've downloaded the site in question, and I've debugged it. The login works as expected. In OnPreRender which runs after the authenticate event on the Login control, the Username and UserId is set correctly. See the screenshot below. But somehow the session is overwritten after OnPreRender. 

I've used most of the authentication code from your site in a test site, and it works without problems. There must be some other code in the site that is causing this. I pretty sure this isn't caused by Webnodes.

Attachments
15 posts

Oh, 

I've informed the guys who made this project and i'll post it here if we find a solution to it.

 

Thanks for the help anyway! :)

1