Exemplo n.º 1
0
        protected void Application_PostAuthenticateRequest()
        {
            HttpCookie authoCookies = Request.Cookies[FormsAuthentication.FormsCookieName];

            if (authoCookies != null)
            {
                try {
                    FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authoCookies.Value);
                    JavaScriptSerializer      js     = new JavaScriptSerializer();
                    User        user        = js.Deserialize <User>(ticket.UserData);
                    MyIdentity  myIdentity  = new MyIdentity(user);
                    MyPrincipal myPrincipal = new MyPrincipal(myIdentity);
                    HttpContext.Current.User = myPrincipal;
                }
                catch (CryptographicException cex)
                {
                    FormsAuthentication.SignOut();
                }
            }
        }
Exemplo n.º 2
0
 public MyPrincipal(MyIdentity _myIdentity)
 {
     MyIdentity = _myIdentity;
 }