Getting Custom Membership Provider Logged in User Name Bug

Posted by Community Admin on 04-Aug-2018 14:14

Getting Custom Membership Provider Logged in User Name Bug

All Replies

Posted by Community Admin on 06-May-2016 00:00

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";

Posted by Community Admin on 09-May-2016 00:00

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
 

Posted by Community Admin on 09-May-2016 00:00

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;

Posted by Community Admin on 10-May-2016 00:00

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
 

This thread is closed