public async Task CreateAsync(string name) { var role = new AuthenticationRole(name); var result = await IdentityManagers.RoleManager.CreateAsync(role); if (!result.Succeeded) throw new InvalidOperationException(string.Join(", ", result.Errors)); }
public static HttpCookie CreateTicket(string Username, AuthenticationRole Role) { return(new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(new FormsAuthenticationTicket(1, Username, DateTime.Now, DateTime.Now.AddMinutes(30), false, Enum.GetName(typeof(AuthenticationRole), Role), FormsAuthentication.FormsCookiePath)))); }