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

Forums / Bugs & Issues / Getting Custom Membership Provider Logged in User Name Bug

Getting Custom Membership Provider Logged in User Name Bug

4 posts, 0 answered
  1. Chance
    Chance avatar
    3 posts
    Registered:
    24 Apr 2015
    06 May
    Link to this post

    Weird issue I can't figure out.  Have a custom membership provider and when I log in as one user, then log out and log in as another user then the custom widgets were I get the logged in users username returns the user name of the first user I logged in as instead of the one after I logged out and logged back in.

     

    I put one of the SiteFinity Logged in User widgets on a page and that shows the correct logged in user name.   I did have it working same way on our Trial version of SiteFinity that is version 8.2.5900.0 but it doesn't work on our Purchased SiteFinity site that is version 9.0.6010.0 so not sure if it has something to do with that or not?

     

     

    Here is code I am using to get the current logged in user:

    var identity = ClaimsManager.GetCurrentIdentity();
    var currentUserGuid = identity.Name;
    if (currentUserGuid != "")
    {
    UserProfileManager profileManager = UserProfileManager.GetManager();
    UserManager userManager = UserManager.GetManager("CustomMembershipProvider");
    User user = userManager.GetUser(currentUserGuid);
    SitefinityProfile profile = null;
    if (user != null)
    {
    profile = profileManager.GetUserProfile<SitefinityProfile>(user);
    }
    return profile.User.UserName.ToString();
    }
    else
    {
    return "Anonymous User";
    }

  2. Dimitri Cools
    Dimitri Cools avatar
    80 posts
    Registered:
    02 Dec 2016
    09 May
    Link to this post
    Hi, 
    I cannot seem to reproduce this using the same steps.
    How are you logging the user out ? Also with a custom widget ? What is the code? Did you also delete the authorization cookie? 
    SecurityManager.Logout();
    SecurityManager.DeleteAuthCookies();
    To delete the .ASPXAUTH cookie created you can clear it by logging out using a call to /Sitefinity/Signout 
    eg.
    Response.Redirect("http://localhost:1202/Sitefinity/SignOut?sts_signout=true&redirect_uri=");


    Do you have the same behavior when you use/test the Default provider? 

    If the issue only happens with your custom provider, what I also can suggest is to open a support ticket as it may be required to send us your project data in order to isolate the reason for this issue.

    Regards,
    Dimitri Cools
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  3. Chance
    Chance avatar
    3 posts
    Registered:
    24 Apr 2015
    09 May in reply to Dimitri Cools
    Link to this post

    I tried using the SiteFinity Login/Logout widget and doing a custom log out with same code you have listed but that didn't make a difference.

    It does work when I turn the caching for the page that the widget is on to 'No Caching' though so I guess I can just do that. 

    My custom provider isn't connected to SiteFinity user profiles either so had to change the code I originally posted to just this:

    var identity = ClaimsManager.GetCurrentIdentity();
    var currentUserGuid = identity.Name;

  4. Dimitri Cools
    Dimitri Cools avatar
    80 posts
    Registered:
    02 Dec 2016
    10 May
    Link to this post
    Hello,

    There are occurrences of similar behavior reported when using a custom membership provider, the solution is - as you already discovered - to disable caching.
    Do you have the same behavior with the Default MembershipProvider? 
    Feel free to open a open a support ticket should you want to pursue this as we will need to inspect your actual project data in order to isolate further.
     
    Regards,
    Dimitri Cools
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
4 posts, 0 answered