示例#1
0
        protected void Application_PostAuthenticateRequest(Object sender, EventArgs e)
        {
            HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName];

            if (authCookie != null)
            {
                FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value);

                PrincessSerializable user    = JsonConvert.DeserializeObject <PrincessSerializable>(authTicket.UserData);
                PrincessPrincipal    newUser = new PrincessPrincipal(user);

                HttpContext.Current.User = newUser;
            }
        }
 public PrincessPrincipal(PrincessSerializable model)
 {
     Profile       = model;
     this.Identity = new GenericIdentity(model.Username);
 }