<?php

/**
* Created by : Julien Dubois.
* Version : 2;
* Update date : 13.05.2022
*/

require_once("../Workers/Connexion.php");
require_once("../Workers/ProfileDBManager.php");
require_once("SessionManager.php");

/**
 * Request Serveur gérant le profile d'utilisateur du site web. 
 * 
 * utilisant un GET pour charger les infomrations du porfile d'utilisateur.
 */
if (isset($_SERVER['REQUEST_METHOD'])) {
    $sessionManager = new SessionManager();
    $profileDBManager = new ProfileDBManager();
    if ($_SERVER['REQUEST_METHOD'] == 'GET') {
        if (isset($_SESSION['isLogged'])) {
            if ($_SESSION['isLogged'] == 'oui') {
                $username = $sessionManager->whoIsLogged();
                $details = $profileDBManager->getUserDetails($username);
                echo $details;
            }else{
                http_response_code(401.1);
            }
        }else{
            http_response_code(401.1);
        }
    }
}
