private async Task CreateUserDefault()
 {
     if (await _repository.CountAsync() == 0)
     {
         var pass = _crypt.Hash("123456@@");
         await _repository.AddAsync(new Models.User
         {
             Name         = "Fúlvio",
             Email        = "*****@*****.**",
             Password     = pass.Hashed,
             PasswordSalt = pass.Salt
         });
     }
     await Task.CompletedTask;
 }
Beispiel #2
0
        public async Task <ActionResult <User> > PostUser(UserCreate model)
        {
            if (ModelState.IsValid)
            {
                var  pass = _crypt.Hash(model.Password);
                User data = new User
                {
                    Email        = model.Email,
                    Name         = model.Name,
                    Password     = pass.Hashed,
                    PasswordSalt = pass.Salt
                };
                await _repository.AddAsync(data);

                return(CreatedAtAction(nameof(GetUser), new { data.Id }, data));
            }
            return(BadRequest(ModelState));
        }