public async Task<bool> ChangePassword(UserPasswordModify userPass)
        {
            var userToModify = await _context.Users.FirstOrDefaultAsync(x => x.Id == userPass.UserId);

            byte[] passwordHash, passwordSalt;
            CreatePasswordHash(userPass.PasswordNew, out passwordHash, out passwordSalt); //jezeli updatowane w metodzie dzieki out rowniez sa tutaj updatowane
            userToModify.PasswordHash = passwordHash;
            userToModify.PasswordSalt = passwordSalt;


            _context.Users.Update(userToModify);

            await _context.SaveChangesAsync();

            return true;
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> ChangePassword([FromBody] UserPasswordModify userToModifyDto)
        {
            var createdUser = await _repo.ChangePassword(userToModifyDto);

            return(StatusCode(201));
        }