1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Sitefinity ClaimsManager - Losing track of user

Sitefinity ClaimsManager - Losing track of user

1 posts, 0 answered
  1. Jacob
    Jacob avatar
    0 posts
    Registered:
    11 Sep 2017
    11 Sep
    Link to this post

    Hey All,

    I have a bug where calling "ClaimsManager.GetCurrentIdentity()" returns an anonymous user. This gets called a couple times in my workflow and works, until the last point.

    Workflow:

    Home Page

    -> User logs in, and is successfully authenticated through Sitefinity (This is all done in one Sitefinity update panel, for this example let's say this is panel A).

    -> User needs to enter in some information in a separate update panel B, which will seamlessly send back the data and update the User profile from Sitefinity. This works fine and we still called that same code to get user identity.

    -> Still on the same page, and on Update Panel B, we got a response back requiring us to enter in one more additional item. Once we submit this item, it is here where the ClaimsManager will not recognize the user, and show the user as anonymous.

     

    In the last two steps, we are doing the same thing of asking claims manager for the current id, just to get the username, and do some work. But it's the second one where the user is forgotten. No logging out of any account is done. The only suspect thing might be the SecurityManager. In the first function with update panel B we authenticate an administrative user via SecurityManager.AuthenticateUser. Typically we log it out right after doing administrative work that needs to be done for a regular user. I have tried commenting that portion out to see if logging out the backend user was causing the issue (Along with clearing cache and IIS). In both cases it still cannot find the user.

     UPDATE:

    I've done some more testing and found in my second step in the workflow, it seems as the logged in user becomes the backend account. Then coming back on the third workflow is simply an anonymous user. Here is an example of what I'm doing to update the user profile, which changes who the ClaimsManager sees as logged in:

    SecurityManager.AuthenticateUser("XXXXXX", "XXXXXX", "XXXXXX", true);
    SitefinityProfile usrProfile = new SitefinityProfile();
    UserProfileManager profileManager = UserProfileManager.GetManager();
    UserManager userManager = UserManager.GetManager();
    User user = userManager.GetUser(userName);
    if (user != null)
    {
     usrProfile = profileManager.GetUserProfile<SitefinityProfile>(user);
    }
               
    //Work done to user profile
    profileManager.SaveChanges();
    userManager.SaveChanges();
    SecurityManager.Logout(); //I've tried using this and not using this

    Please let me know if you need any more details.

    Thanks,

1 posts, 0 answered