<?php
require("../snippets/autoload.php");

$entity = new UserAccount();

$rules = array();

$exclude = array();

SanitizeRequest($rules, $exclude);

$entity->Password = $_POST["Password"];
if( strlen($entity->Password)<7 ){
    $response_request["type"] = "error";
    $response_request["title"] = _("Error presented");
    $response_request["content"] = _("Password must have at least 7 chars.");
}else{
    $entity->Id = $LoggedUser;
    $entity->Password = $utils->EncryptWithoutReverse($entity->Password);
    if($entity->UpdatePassword()){
        $response_request["type"] = "success";
        $response_request["title"] = _("Successful process");
        $response_request["content"] = _("Your password was updated!");
    }else{
        $response_request["type"] = "error";
        $response_request["title"] = _("Error presented");
        $response_request["content"] = _("An unexpected error happened");
    }
}


echo json_encode($response_request);