Exemple #1
0
        private static void CreateAdminUser()
        {
            IRepository repository = DependencyResolver.Current.GetService<IRepository>();
            IUserService userService = DependencyResolver.Current.GetService<IUserService>();
            
            if(repository.Get<IApplicationUser>().Count() <= 0)
            {
                ApplicationUser user = new ApplicationUser
                {
                    Id = Guid.NewGuid().ToString(),
                    UserName = "******"
                };

                UserManager<ApplicationUser, string> userManager = new UserManager<ApplicationUser, string>(userService);
                IdentityResult result = userManager.Create<ApplicationUser, string>(user, "admin1234");
            }
        }
Exemple #2
0
        public Task SetPasswordHashAsync(ApplicationUser user, string passwordHash)
        {
            if (string.IsNullOrWhiteSpace(passwordHash))
            {
                IUserPassword userPassword = Repository.GetFor<IUserPassword, UserPassword>(up => up.UserId == user.Id);
                Repository.Delete(userPassword);
            }
            else
            {
                IUserPassword userPassword = new UserPassword
                {
                    Id = Guid.NewGuid().ToString(),
                    UserId = user.Id,
                    PasswordHash = passwordHash
                };
                Repository.Save(userPassword);
            }


            return Task.FromResult<object>(null);
        }
Exemple #3
0
 public Task<int> IncrementAccessFailedCountAsync(ApplicationUser user)
 {
     throw new NotImplementedException();
 }
Exemple #4
0
 public Task<DateTimeOffset> GetLockoutEndDateAsync(ApplicationUser user)
 {
     throw new NotImplementedException();
 }
Exemple #5
0
 public Task<bool> GetLockoutEnabledAsync(ApplicationUser user)
 {
     return Task.FromResult<bool>(false);
 }
Exemple #6
0
 public Task<bool> HasPasswordAsync(ApplicationUser user)
 {
     IUserPassword userPassword = Repository.GetFor<IUserPassword, UserPassword>(up => up.UserId == user.Id);
     return Task.FromResult<bool>(userPassword != null && !string.IsNullOrWhiteSpace(userPassword.PasswordHash));
 }
Exemple #7
0
 public Task<string> GetPasswordHashAsync(ApplicationUser user)
 {
     IUserPassword userPassword = Repository.GetFor<IUserPassword, UserPassword>(up => up.UserId == user.Id);
     return Task.FromResult<string>(userPassword.PasswordHash);
 }
Exemple #8
0
 public Task UpdateAsync(ApplicationUser user)
 {
     Repository.Save(user);
     return Task.FromResult<object>(null);
 }
Exemple #9
0
 public Task SetTwoFactorEnabledAsync(ApplicationUser user, bool enabled)
 {
     throw new NotImplementedException();
 }
Exemple #10
0
 public Task<bool> GetTwoFactorEnabledAsync(ApplicationUser user)
 {
     return Task.FromResult<bool>(false);
 }