Exemplo n.º 1
0
        private UserIdentity LoadIdentity(HttpContext context)
        {
            SecurityTicket ticket;

            var persistor = new TicketPersistor();

            var cookie = context.Request.Cookies[CookieName];
            if (cookie == null)
            {
                ticket = new SecurityTicket();
            }
            else
            {
                ticket = persistor.Deserialize(cookie.Value);
            }

            var user = new UserIdentity(ticket);

            return user;
        }
Exemplo n.º 2
0
        private void SaveIdentity(HttpContext context, UserIdentity user)
        {
            if (user == null) return;

            var persistor = new TicketPersistor();

            var ticket = user.Ticket;
            var data = persistor.Serialize(ticket);

            var cookie = new HttpCookie(CookieName);
            cookie.Value = data;
            context.Response.Cookies.Add(cookie);
        }