Copied to clipboard

Flag this post as spam?

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


  • Thomas 315 posts 602 karma points c-trib
    Aug 28, 2020 @ 10:46
    Thomas
    0

    Backoffice Auth Umbraco 8

    Hey

    I'm trying to get the current logged in User in the backoffice..

    I'm using an Auth that I found for Hangfire..

    Current.UmbracoContext.Security.CurrentUser return null... The same is with the http.GetUmbracoAuthTicket(9;

    public bool Authorize(DashboardContext context)
        {
            var http = new HttpContextWrapper(HttpContext.Current);
            var ticket = http.GetUmbracoAuthTicket();
            http.AuthenticateCurrentRequest(ticket, true);
    
            var user = Current.UmbracoContext.Security.CurrentUser;
    
            return user != null && user.Groups.Any(g => g.Alias == "admin" || g.Alias == "subAdmin");
    
        }
    

    Anyone else that have done some similar ??

  • Enkosi 11 posts 86 karma points
    Dec 17, 2020 @ 07:06
    Enkosi
    0

    You can try the following to get the current logged in User:

    var wrapper = new HttpContextWrapper(HttpContext.Current);
    var currentUser = wrapper.GetCurrentIdentity(true);
    

    Hope it helps

Please Sign in or register to post replies

Write your reply to:

Draft