Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Christian John Schmidt 4 posts 104 karma points
    26 days ago
    Christian John Schmidt
    0

    How to check if backend user is logged in?

    I have a customer that wants an adminbar to appear on their webpage if they are logged into the backend. I am trying to do this from an UmbracoViewPage, and after some googling, I've found the two following solutions, however they don't seem to work:

     bool isLoggedIn = UmbracoContext.Security.IsAuthenticated();
    

    This always returns false.

    bool isLoggedIn = UmbracoContext.Security.CurrentUser != null;
    

    CurrrentUser is always null.

    Any help would be appreciated!

  • Christian John Schmidt 4 posts 104 karma points
    26 days ago
    Christian John Schmidt
    100

    I found the solution:

    HttpContextBase wrapper = new HttpContextWrapper(HttpContext.Current);
    UmbracoBackOfficeIdentity user = wrapper.GetCurrentIdentity(true);
    
    bool isLoggedIn = user != null;
    
Please Sign in or register to post replies

Write your reply to:

Draft