Copied to clipboard

Flag this post as spam?

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


  • Anthony Kallay 3 posts 74 karma points
    Oct 23, 2017 @ 10:06
    Anthony Kallay
    1

    Umbraco back office plugin - not authorized login page

    Hi,

    I have created a custom umbraco plugin that is accessed by a custom area route

    /umbraco/backoffice/plugins/secure

    The controllers are secured using the base class UmbracoAuthorizedController

    This all works fine and when logged in i can browse the custom area, however when i am not logged into umbraco and i visit the url i just get the default iis

    HTTP Error 401.0 - You must login to view this resource.

    How can i make it redirect to the umbraco login page (with a return url back to custom area)

    Any ideas? Cheers Anthony

  • Alastair Todd 44 posts 142 karma points
    Dec 17, 2017 @ 08:37
    Alastair Todd
    0

    Found a reasonably hacky way.

    First inherit from UmbracoController not UmbracoAuthorizedController as we'll have to check security ourselves.

    Then add this to the Controller constructor

     if (!UmbracoContext.Current.Security.ValidateCurrentUser())
                    System.Web.HttpContext.Current.Response.Redirect("/umbraco", true);
    
Please Sign in or register to post replies

Write your reply to:

Draft