Getting Custom Membership Provider Logged in User Name Bug
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";
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="
);
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;
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