Copied to clipboard

Flag this post as spam?

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


  • Tim 1193 posts 2675 karma points MVP 4x c-trib
    Jul 07, 2014 @ 17:04
    Tim
    0

    Using Application_AuthenticateRequest to set custom principal for Members

    Hi,

    I've written a custom membership provider (basically it just inherits the standard provider and stores some extra stuff in the UserData of the FormsAuthentication ticket), that all works fine, but I'd like to be able to set a custom principal in the Application_AuthenticateRequest event.

    I've managed to wire into the event happily, however, I've hit a snag. The event is fired for both Members, and back office Users. How do I tell if the current user is a member or user? I presume there must be a way of telling this, as otherwise users would be able to log into the back office and vice versa.......

    So my question is, how do I tell the difference in my code? They both fire the event, but I can't find an obvious way to tell the two types of user apart.

    Any help greatly appreciated!

  • Ajit 7 posts 67 karma points
    Jan 27, 2016 @ 15:55
    Ajit
    0

    One could use URL to determine if it umbraco backend:

        protected void Application_AuthenticateRequest(Object sender, EventArgs e)
        {
            if (!Request.Url.Authority.StartsWith("umbracocms")
            {
                //create custom principal
            }
        }
    

    p.s. Use Init to register Application_AuthenticateRequest event handler:

        public void Init(HttpApplication application)
        {
            application.AuthenticateRequest += new EventHandler(Application_AuthenticateRequest);
        }   
    
Please Sign in or register to post replies

Write your reply to:

Draft