No API for UserManager.GetCurrentUser?
Please add this into the API. Right now, it seems the only way to do this is:
userManager.GetUser(SecurityManager.GetCurrentUserName())
Hello Basem,
Why not use the GetCurrentUser() method of SecurityManager?
SecurityManager.GetCurrentUser();
//Returns the current user
Because this does not cast up from SitefinityPrincipal to a Telerik User model object. I would like to work with the Telerik.Sitefinity.Security.Model.User type since that has all aspects of the logged in member.
Hi Basem,
I see your point now, indeed this is not very conveninent, asyou'll need to get the CurrentUserName or CurrentUserId from SecurityManager and then pass it to UserManager.GetUser(). I have logged your request in our system and we'll be working on it. Thanks for the constructive feedback, we appreciate it.
Best wishes,
Boyan Barnev
the Telerik team
You could use the following snippet to get a correct reference to the currently logged User (Telerik.Sitefinity.Security.Model.User) - this takes into account the possibility to have different membership providers:
var currentIdentity = SecurityManager.GetCurrentUser().Identity
as
SitefinityIdentity;
var providerName = currentIdentity.Provider;
var userId = currentIdentity.Id;
var user = UserManager.GetManager(providerName).GetUser(userId);
Thanks Lupi. This works perfectly.
My suggestion was in hopes of something like this:
var user = userManager.GetCurrentUser();
var user = userManager.GetCurrentUser(providerName);
Hi Basem,
I guess we can add this as well, or better, provide a FluentAPI.
Best wishes,this seems works with multiple providers :)
if(Context.User.Identity.IsAuthenticated)
if (UserManager.UserExistsInAnyProvider(SecurityManager.CurrentUserId))
var user = UserManager.FindUser(SecurityManager.CurrentUserId);
tipoUsuario = user.ProviderName;