Exemplo n.º 1
0
        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {
            HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName];

            if (authCookie == null) return;

            FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value);

            var identity = new ZenMuIdentity(authTicket.Name);
            var principal = new ZenMuPrincipal(identity);
            Context.User = principal;
            Thread.CurrentPrincipal = principal;
        }
Exemplo n.º 2
0
 private bool TryCreatePlayer(string authCookie, IWebSocketConnection socket, out Player result)
 {
     try
     {
         var authTicket = FormsAuthentication.Decrypt(authCookie);
         var identity = new ZenMuIdentity(authTicket.Name);
         var principal = new ZenMuPrincipal(identity);
         result = new Player(socket, principal);
     }
     catch(Exception e)
     {
         result = null;
         return false;
     }
     return true;
 }