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

Forums / Suggestions / No API for UserManager.GetCurrentUser?

No API for UserManager.GetCurrentUser?

9 posts, 0 answered
  1. Basem
    Basem avatar
    131 posts
    Registered:
    22 Dec 2010
    29 Apr 2011
    Link to this post
    Please add this into the API. Right now, it seems the only way to do this is:
    userManager.GetUser(SecurityManager.GetCurrentUserName())
  2. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    06 Dec 2016
    02 May 2011
    Link to this post
    Hello Basem,

    Why not use the GetCurrentUser() method of SecurityManager?
    SecurityManager.GetCurrentUser();
    //Returns the current user


    Regards,
    Boyan Barnev
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  3. Basem
    Basem avatar
    131 posts
    Registered:
    22 Dec 2010
    02 May 2011
    Link to this post
    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.
  4. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    06 Dec 2016
    05 May 2011
    Link to this post
    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
    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 Public Issue Tracking system and vote to affect the priority of the items
  5. Lupi
    Lupi avatar
    38 posts
    Registered:
    17 May 2004
    20 May 2011
    Link to this post
    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);
  6. Ed Hardy
    Ed Hardy avatar
    17 posts
    Registered:
    28 Aug 2012
    20 May 2011
    Link to this post
    Thanks Lupi. This works perfectly.
  7. Basem
    Basem avatar
    131 posts
    Registered:
    22 Dec 2010
    20 May 2011
    Link to this post
    My suggestion was in hopes of something like this:

    var user = userManager.GetCurrentUser();
    var user = userManager.GetCurrentUser(providerName);
  8. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    24 May 2011
    Link to this post
    Hi Basem,

    I guess we can add this as well, or better, provide a FluentAPI.

    Best wishes,
    Georgi
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  9. Jose Antonio de Alarcon
    Jose Antonio de Alarcon avatar
    10 posts
    Registered:
    29 Jun 2009
    18 Oct 2012 in reply to Basem
    Link to this post
    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;
     
                        }
                    }
9 posts, 0 answered