Ejemplo n.º 1
0
        public async Task <IActionResult> Put(string username, string password, [FromBody] UserDto dto)
        {
            var user = await _users.FindAsync(username);

            if (!await _users.CheckPasswordAsync(user, password))
            {
                return(Unauthorized());
            }

            user.UserName = dto.Name;
            await _users.UpdateAsync(user);

            if (!string.IsNullOrEmpty(dto.Password))
            {
                await _users.ChangePasswordAsync(user, password, dto.Password);
            }

            return(Ok());
        }