Copied to clipboard

Flag this post as spam?

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


  • Peter 4 posts 73 karma points
    Mar 09, 2018 @ 07:50
    Peter
    0

    How can I force authentication for all users?

    Every time I try to search for authentication I just get a bunch of pages describing how to auth back office users. I want to use the CMS as an intranet, and thus need to enforce authentication before any user can access any page - a site wide authentication. Is this possible? If so, where can I find documentation on how to set it up?

  • Steve Morgan 1345 posts 4452 karma points c-trib
    Mar 09, 2018 @ 09:51
    Steve Morgan
    0

    Hi Peter,

    I would do this using a Default Custom Controller. See https://our.umbraco.org/documentation/implementation/default-routing/Controller-Selection/

    In the default method just get and check the current user, if it's null redirect to the login page (remember to make the login page and any error pages etc exceptions on the user check or redirect loop will occur),

    Something simple like:

    var currentUser = Member.GetCurrentMember();
    
      if (currentUser == null)
       {    
            return RedirectToUmbracoPage(1090);    // whatever your login page id is
       }
    

    If you want a quick hack you could just add the above to your master template(s).

    HTH

    Steve

Please Sign in or register to post replies

Write your reply to:

Draft