Brandy.Security.Web.BrandyAutentificationModule.OnAuthenticateRequest C# (CSharp) Method

OnAuthenticateRequest() private static method

private static OnAuthenticateRequest ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void
        private static void OnAuthenticateRequest(object sender, EventArgs e)
        {
            var application = (HttpApplication) sender;

            var context = application.Context;

            if (context.User != null && context.User.Identity.IsAuthenticated)
                return;

            var cookieName = FormsAuthentication.FormsCookieName;

            var cookie = application.Request.Cookies[cookieName.ToUpper()];

            if (cookie == null)
                return;
            try
            {
                var ticket = FormsAuthentication.Decrypt(cookie.Value);
                var identity = new CustomIdentity(AccountEntry.Deserialize(ticket.UserData), ticket.Name);
                var principal = new GenericPrincipal(identity, identity.GetRoles());
                context.User = principal;
                Thread.CurrentPrincipal = principal;
            }
            catch
            {
            }
        }
BrandyAutentificationModule