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; }
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; }