public static HttpCookie CreateAuthCookie(string userName, bool rememberUser) { HttpCookie authCookie = FormsAuthentication.GetAuthCookie(userName, rememberUser); FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value); string userData = String.Join(",", MADRoles.GetRolesForUser(userName).Select(el => el.RoleName)); var newTicket = new FormsAuthenticationTicket( ticket.Version, ticket.Name, ticket.IssueDate, ticket.Expiration, ticket.IsPersistent, userData, ticket.CookiePath ); authCookie.Value = FormsAuthentication.Encrypt(newTicket); return(authCookie); }
private static string GetRolesForUser(string userName) { return(String.Join(",", MADRoles.GetRolesForUser(userName))); }