Copied to clipboard

Flag this post as spam?

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


  • HP21 3 posts 72 karma points
    Feb 11, 2016 @ 15:08
    HP21
    0

    Best way to restrict access to a page on the website to an umbraco admin user

    We have a page on our site that we only want the umbraco admin user to have access to.

    Could anyone recommend the best way to achieve this? Or would I need to create a custom section and add the page there.

    Thanks.

  • Marc Goodson 2149 posts 14377 karma points MVP 9x c-trib
    Feb 12, 2016 @ 00:09
    Marc Goodson
    0

    Hi HP21

    A custom dashboard / section probably makes most sense here.

    But I suppose you could in theory use Umbraco's UserService, to pull back the current logged in back office user: something a little bit like this:

    var userService = ApplicationContext.Current.Services.UserService;
     var currentUser = userService.GetByUsername(HttpContext.Current.User.Identity.Name);
    if (currentUser != null &&  currentUser.UserType.Alias == "Administrator"){
    
    // do your admin stuff here
    }
    else {
     // don't show the page
    }
    
  • HP21 3 posts 72 karma points
    Feb 12, 2016 @ 10:10
    HP21
    0

    Thank you Marc for your help.

Please Sign in or register to post replies

Write your reply to:

Draft