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"); } }
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); }
public Task<int> IncrementAccessFailedCountAsync(ApplicationUser user) { throw new NotImplementedException(); }
public Task<DateTimeOffset> GetLockoutEndDateAsync(ApplicationUser user) { throw new NotImplementedException(); }
public Task<bool> GetLockoutEnabledAsync(ApplicationUser user) { return Task.FromResult<bool>(false); }
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)); }
public Task<string> GetPasswordHashAsync(ApplicationUser user) { IUserPassword userPassword = Repository.GetFor<IUserPassword, UserPassword>(up => up.UserId == user.Id); return Task.FromResult<string>(userPassword.PasswordHash); }
public Task UpdateAsync(ApplicationUser user) { Repository.Save(user); return Task.FromResult<object>(null); }
public Task SetTwoFactorEnabledAsync(ApplicationUser user, bool enabled) { throw new NotImplementedException(); }
public Task<bool> GetTwoFactorEnabledAsync(ApplicationUser user) { return Task.FromResult<bool>(false); }