private async Task CreateUsers(StudioContext context) { var users = new[] { new User { Active = true, BirthDate = DateTime.Now - TimeSpan.FromDays(6570), Cpf = _settings.DefaultUserCpf, Email = _settings.DefaultUserEmail, Name = "Giovanni Sunner", Password = _hash.Of(_settings.DefaultUserPassword), Phone = "11940028922", SocialName = null }, new User { Active = true, BirthDate = DateTime.Now - TimeSpan.FromDays(14600), Cpf = _settings.SuperUserCpf, Email = _settings.SuperUserEmail, Name = "Silva Gunther", Password = _hash.Of(_settings.SuperUserPassword), Phone = "11910101010", SocialName = "Gilva Sunther" } }; foreach (var user in users) { await context.Users.AddAsync(user); } await context.SaveChangesAsync(); }
public Employee ToModel(Occupation occupation, IPasswordHash passwordHash) { return(new Employee { AccessLevel = AccessLevel, Gender = Gender, Occupation = occupation, OccupationId = occupation.Id, ParticipatingPhotoShoots = null, Rg = Rg, User = new User { Active = true, BirthDate = BirthDate, Cpf = Misc.StripCpf(Cpf), Email = Email, Name = Name, Password = Password == null ? null : passwordHash.Of(Password), Phone = Phone, SocialName = SocialName }, UserId = Cpf }); }
private async Task <User?> AuthenticateUser(InputLogin login) { var user = await FindUserWithLogin(login.Login); var hash = _passwordHash.Of(login.Password); if (user != null) { if (user.Password != hash) { user = null; } } return(user); }
public void HashPassword(IPasswordHash passwordHash) { Password = passwordHash.Of(Password); }