Beispiel #1
0
        public async Task<IdentityResult> RegisterUser(RegisterUserBindingModel registerUserModel)
        {
            AbitInfoIdentityUser user = new AbitInfoIdentityUser
            {
                UserName = registerUserModel.Username,
                CreationTime = DateTime.UtcNow,
                Email = registerUserModel.Email,
                EmailConfirmed = true,
                Banned = false
            };

            using (IdentityDbContext<AbitInfoIdentityUser> context = _identityProvider.Context)
            {
                UserManager<AbitInfoIdentityUser> userManager =
                    _identityProvider.GetUserManager(context);

                IdentityResult result = await userManager.
                    CreateAsync(user, registerUserModel.Password);
                if (result.Succeeded)
                {
                    userManager.AddToRole(user.Id, "User");
                }
                return result;
            }
        }
Beispiel #2
0
 public async Task<IdentityResult> CreateAsync(AbitInfoIdentityUser user)
 {
     using (IdentityDbContext<AbitInfoIdentityUser> context = _identityProvider.Context)
     {
         UserManager<AbitInfoIdentityUser> userManager =
             _identityProvider.GetUserManager(context);
         var result = await userManager.CreateAsync(user);
         return result;
     }
 }
Beispiel #3
0
 public async Task<ClaimsIdentity> CreateIdentity(
     AbitInfoIdentityUser user, string authenticationType)
 {
     using (IdentityDbContext<AbitInfoIdentityUser> context = _identityProvider.Context)
     {
         var userManager = _identityProvider.GetUserManager(context);
         return await userManager.CreateIdentityAsync(user, authenticationType);
     }
 }