Exemplo n.º 1
0
        public static FormsAuthenticationTicket CreateTicket(mUser user, IList<mRole> roles, IList<mAuth> auths)
        {
            var userInfo = new UserIdentity {
                Id = user.Id.ToString(),
                Name = user.Name,
                Email = user.Id.ToString(),
                Roles = String.Join(",", roles),
                Auths = String.Join(",", auths)
            };

            var ticket = new FormsAuthenticationTicket(1,
                user.Name,
                DateTime.Now,
                DateTime.Now.Add(FormsAuthentication.Timeout),
                false,
                userInfo.ToString());

            return ticket;
        }