コード例 #1
0
ファイル: Roles.cs プロジェクト: bcjobs/infra
        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));
        }
コード例 #2
0
 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))));
 }