public async Task <ActionResult <Gebruiker> > PostGebruiker(Gebruiker gebruiker) { var salt = HashService.GenerateSalt(); var hashedWachtwoord = HashService.Create(gebruiker.Wachtwoord, salt); gebruiker.Wachtwoord = hashedWachtwoord; gebruiker.Salt = salt; _context.Gebruikers.Add(gebruiker); await _context.SaveChangesAsync(); return(Ok()); }
public async Task Handle(UserCreatedEvent @event) { CreateUserCredentialsDTO userIn = @event.User; string salt = _hashService.GenerateSalt(); AuthUser userToCreate = new AuthUser { Id = userIn.Id, UserName = userIn.UserName, Email = userIn.Email, PasswordSalt = salt, PasswordHash = _hashService.GenerateHash(userIn.PasswordHash, salt) }; Role role = new Role { RoleName = @event.Role.RoleName }; await _authRepository.Create(userToCreate, role); await Task.CompletedTask; }
public static void Initialize(AngularContext context) { context.Database.EnsureCreated(); if (context.Gebruikers.Any()) { return; } var salt = HashService.GenerateSalt(); var gebruikers = new Gebruiker[] { new Gebruiker(context) { Gebruikersnaam = "Wesley", Email = "*****@*****.**", Salt = salt, Wachtwoord = HashService.Create("wesley", salt), ImageUrl = "https://res.cloudinary.com/dnjmym7yo/image/upload/v1574867798/profile_q2bu5r.png" }, new Gebruiker(context) { Gebruikersnaam = "SirTurtle", Email = "*****@*****.**", Salt = salt, Wachtwoord = HashService.Create("sirturtle", salt), ImageUrl = "https://res.cloudinary.com/dnjmym7yo/image/upload/v1574867798/profile_q2bu5r.png" }, new Gebruiker(context) { Gebruikersnaam = "SirFailure", Email = "*****@*****.**", Salt = salt, Wachtwoord = HashService.Create("sirfailure", salt), ImageUrl = "https://res.cloudinary.com/dnjmym7yo/image/upload/v1574867798/profile_q2bu5r.png" }, new Gebruiker(context) { Gebruikersnaam = "Ali", Email = "*****@*****.**", Salt = salt, Wachtwoord = HashService.Create("ali123", salt), ImageUrl = "https://res.cloudinary.com/dnjmym7yo/image/upload/v1574867798/profile_q2bu5r.png" }, new Gebruiker(context) { Gebruikersnaam = "Din", Email = "*****@*****.**", Salt = salt, Wachtwoord = HashService.Create("din123", salt), ImageUrl = "https://res.cloudinary.com/dnjmym7yo/image/upload/v1574867798/profile_q2bu5r.png" }, new Gebruiker(context) { Gebruikersnaam = "Lenny", Email = "*****@*****.**", Salt = salt, Wachtwoord = HashService.Create("lenny123", salt), ImageUrl = "https://res.cloudinary.com/dnjmym7yo/image/upload/v1574867798/profile_q2bu5r.png" }, }; foreach (Gebruiker g in gebruikers) { context.Gebruikers.Add(g); } context.SaveChanges(); }