diff --git a/Sources/src/app/controller/AuthController.php b/Sources/src/app/controller/AuthController.php index e6620fe7..6a88b292 100644 --- a/Sources/src/app/controller/AuthController.php +++ b/Sources/src/app/controller/AuthController.php @@ -1,82 +1,82 @@ redirectToRoute('blog_index'); -// } +class AuthController extends BaseController +{ + #[Route('/login', name: 'login')] + public function login(?string $username, ?string $password ,IRequest $request): Response { + // if user is already logged in, don't display the login page again + if ($user) { + return $this->redirectToRoute('blog_index'); + } -// // this statement solves an edge-case: if you change the locale in the login -// // page, after a successful login you are redirected to a page in the previous -// // locale. This code regenerates the referrer URL whenever the login page is -// // browsed, to ensure that its locale is always the current one. -// $this->saveTargetPath($request->getSession(), 'main', $this->generateUrl('admin_index')); + // this statement solves an edge-case: if you change the locale in the login + // page, after a successful login you are redirected to a page in the previous + // locale. This code regenerates the referrer URL whenever the login page is + // browsed, to ensure that its locale is always the current one. + $this->saveTargetPath($request->getSession(), 'main', $this->generateUrl('admin_index')); -// return $this->render('security/login.html.twig', [ -// // last username entered by the user (if any) -// 'last_username' => $helper->getLastUsername(), -// // last authentication error (if any) -// 'error' => $helper->getLastAuthenticationError(), -// ]); -// } + return $this->render('security/login.html.twig', [ + // last username entered by the user (if any) + 'last_username' => $helper->getLastUsername(), + // last authentication error (if any) + 'error' => $helper->getLastAuthenticationError(), + ]); + } -// #[Route('/login', name: 'login')] -// public function login(?string $username, ?string $password ,IRequest $request): Response { -// // if user is already logged in, don't display the login page again -// if ($user) { -// return $this->redirectToRoute('blog_index'); -// } + // #[Route('/login', name: 'login')] + // public function login(?string $username, ?string $password ,IRequest $request): Response { + // // if user is already logged in, don't display the login page again + // if ($user) { + // return $this->redirectToRoute('blog_index'); + // } -// // this statement solves an edge-case: if you change the locale in the login -// // page, after a successful login you are redirected to a page in the previous -// // locale. This code regenerates the referrer URL whenever the login page is -// // browsed, to ensure that its locale is always the current one. -// $this->saveTargetPath($request->getSession(), 'main', $this->generateUrl('admin_index')); + // // this statement solves an edge-case: if you change the locale in the login + // // page, after a successful login you are redirected to a page in the previous + // // locale. This code regenerates the referrer URL whenever the login page is + // // browsed, to ensure that its locale is always the current one. + // $this->saveTargetPath($request->getSession(), 'main', $this->generateUrl('admin_index')); -// return $this->render('security/login.html.twig', [ -// // last username entered by the user (if any) -// 'last_username' => $helper->getLastUsername(), -// // last authentication error (if any) -// 'error' => $helper->getLastAuthenticationError(), -// ]); -// } + // return $this->render('security/login.html.twig', [ + // // last username entered by the user (if any) + // 'last_username' => $helper->getLastUsername(), + // // last authentication error (if any) + // 'error' => $helper->getLastAuthenticationError(), + // ]); + // } -// function inscription() { -// $model = new ModelVisitor(); -// $log=Validation::clean_string($_POST['pseudo']); -// $mdp=Validation::clean_string($_POST['password']); -// if($model->createAUser($log,$mdp)){ -// if(ModelUser::login($log, $mdp)){ -// UserControler::displayView(); -// } -// } -// } -// function login() { -// $model = new ModelVisitor(); -// if(!isset($_POST['pseudo']) || !isset($_POST['password'])) throw new Exception(" some wrong with credentials !!!!!"); -// $log=Validation::clean_string($_POST['pseudo']); -// $mdp=Validation::clean_string($_POST['password']); -// if(ModelUser::login($log, $mdp)){ -// UserControler::displayView(); -// } + function inscription() { + $model = new ModelVisitor(); + $log=Validation::clean_string($_POST['pseudo']); + $mdp=Validation::clean_string($_POST['password']); + if($model->createAUser($log,$mdp)){ + if(ModelUser::login($log, $mdp)){ + UserControler::displayView(); + } + } + } + function connexion(){ + $model = new ModelVisitor(); + if(!isset($_POST['pseudo']) || !isset($_POST['password'])) throw new Exception(" some wrong with credentials !!!!!"); + $log=Validation::clean_string($_POST['pseudo']); + $mdp=Validation::clean_string($_POST['password']); + if(ModelUser::login($log, $mdp)){ + UserControler::displayView(); + } -// } + } -// } +} ?> \ No newline at end of file diff --git a/Sources/src/app/controller/CoachController.php b/Sources/src/app/controller/CoachController.php index db95d553..a7614f96 100644 --- a/Sources/src/app/controller/CoachController.php +++ b/Sources/src/app/controller/CoachController.php @@ -1,49 +1,35 @@ coachManager = $dataManager->coachMgr; -// $this->security = $security; -// } - -// #[Route(path: '/', name: 'home', methods: ['GET'])] -// public function index(): Response -// { -// return $this->render('./page/home.html.twig',[ -// 'css' => $this->preference->getCookie(), -// 'pp' => "test2", -// 'user' => "Doe", -// 'role' => "Athlète", -// 'friendship' => [], -// 'analyzes' => [], -// 'mails' => [], -// 'users' => [], -// 'infoUser' => [], -// 'exos' => [], -// 'member' => [] -// ]); -// } + public function __construct(DataManager $dataManager, Security $security) + { + session_start(); + $this->coachManager = $dataManager->coachMgr; + $this->security = $security; + $this->preference = new Preferences(); + } // #[Route('/global-stats', name: 'coach_global_stats', methods: ['GET'])] // public function globalStats(): Response @@ -52,42 +38,24 @@ // return $this->render('coach/global_stats.html.twig'); // } -// #[Route(path: '/exercice', name: 'exercice', methods: ['GET'])] // 8 -// public function exercice(): Response -// { -// return $this->render('./page/exercice.html.twig',[ -// 'css' => $this->preference->getCookie(), -// 'pp' => "test2", -// 'user' => "Doe", -// 'role' => "Athlète", -// 'friendship' => [], -// 'analyzes' => [], -// 'mails' => [], -// 'users' => [], -// 'infoUser' => [], -// 'exos' => [], -// 'member' => [] -// ]); -// } - -// #[Route(path: '/coaching', name: 'coaching', methods: ['GET'])] -// public function coaching(): Response -// { -// return $this->render('./page/coaching.html.twig',[ -// 'css' => $this->preference->getCookie(), -// 'pp' => "test2", -// 'user' => "Doe", -// 'role' => "Athlète", -// 'friendship' => [], -// 'analyzes' => [], -// 'mails' => [], -// 'users' => [], -// 'infoUser' => [], -// 'exos' => [], -// 'member' => [] -// ]); -// } + #[Route(path: '/coaching', name: 'coaching', methods: ['GET'])] + public function coaching(): Response + { + return $this->render('./page/coaching.html.twig',[ + 'css' => $this->preference->getCookie(), + 'pp' => "test2", + 'user' => "Doe", + 'role' => "Coach", + 'friendship' => [], + 'analyzes' => [], + 'mails' => [], + 'users' => [], + 'infoUser' => [], + 'exos' => [], + 'member' => [] + ]); + } // #[Route('/list-athletes', name: 'coach_list_athletes')] // public function listAthletes(): Response @@ -125,4 +93,4 @@ // // } -// } \ No newline at end of file +} \ No newline at end of file diff --git a/Sources/src/app/controller/Controller.php b/Sources/src/app/controller/Controller.php index 7450300d..18cae60e 100644 --- a/Sources/src/app/controller/Controller.php +++ b/Sources/src/app/controller/Controller.php @@ -22,41 +22,41 @@ class Controller extends BaseController $this->preference = new Preferences(); } - #[Route(path: '/', name: 'index', methods: ['GET'])] - public function index(): Response - { - return $this->render('./page/index.html',[ - 'css' => $this->preference->getCookie(), - 'pp' => "test2", - 'user' => "Doe", - 'role' => "Athlète", - 'friendship' => [], - 'analyzes' => [], - 'mails' => [], - 'users' => [], - 'infoUser' => [], - 'exos' => [], - 'member' => [] - ]); - } - - #[Route(path: '/home', name: 'home', methods: ['GET'])] - public function home(): Response - { - return $this->render('./page/home.html.twig',[ - 'css' => $this->preference->getCookie(), - 'pp' => "test2", - 'user' => "Doe", - 'role' => "Athlète", - 'friendship' => [], - 'analyzes' => [], - 'mails' => [], - 'users' => [], - 'infoUser' => [], - 'exos' => [], - 'member' => [] - ]); - } + // #[Route(path: '/', name: 'index', methods: ['GET'])] + // public function index(): Response + // { + // return $this->render('./page/index.html',[ + // 'css' => $this->preference->getCookie(), + // 'pp' => "test2", + // 'user' => "Doe", + // 'role' => "Athlète", + // 'friendship' => [], + // 'analyzes' => [], + // 'mails' => [], + // 'users' => [], + // 'infoUser' => [], + // 'exos' => [], + // 'member' => [] + // ]); + // } + + // #[Route(path: '/home', name: 'home', methods: ['GET'])] + // public function home(): Response + // { + // return $this->render('./page/home.html.twig',[ + // 'css' => $this->preference->getCookie(), + // 'pp' => "test2", + // 'user' => "Doe", + // 'role' => "Athlète", + // 'friendship' => [], + // 'analyzes' => [], + // 'mails' => [], + // 'users' => [], + // 'infoUser' => [], + // 'exos' => [], + // 'member' => [] + // ]); + // } #[Route(path: '/analyses', name: 'analyses', methods: ['GET'])] public function analyses(): Response @@ -450,180 +450,180 @@ class Controller extends BaseController ]); } - #[Route(path: '/coaching', name: 'coaching', methods: ['GET'])] - public function coaching(): Response - { - return $this->render('./page/coaching.html.twig',[ - 'css' => $this->preference->getCookie(), - 'pp' => "test2", - 'user' => "Doe", - 'role' => "Athlète", - 'friendship' => [], - 'analyzes' => [], - 'mails' => [], - 'users' => [], - 'infoUser' => [], - 'exos' => [], - 'member' => [] - ]); - } - - #[Route(path: '/mail', name: 'mail', methods: ['GET'])] - public function mail(): Response - { - return $this->render('./page/mail.html.twig',[ - 'css' => $this->preference->getCookie(), - 'pp' => "test2", - 'user' => "Doe", - 'role' => "Athlète", - 'friendship' => [], - 'analyzes' => [], - 'mails' => [], - 'users' => [], - 'infoUser' => [], - 'exos' => [], - 'member' => [] - ]); - } - - #[Route(path: '/import', name: 'import', methods: ['GET'])] - public function import(): Response - { - return $this->render('./page/import.html.twig',[ - 'css' => $this->preference->getCookie(), - 'pp' => "test2", - 'user' => "Doe", - 'role' => "Athlète", - 'friendship' => [], - 'analyzes' => [], - 'mails' => [], - 'users' => [], - 'infoUser' => [], - 'exos' => [], - 'member' => [] - ]); - } - - #[Route(path: '/settings', name: 'settings', methods: ['GET'])] - public function settings(IRequest $req): Response - { - return $this->render('./page/settings.html.twig',[ - 'css' => $this->preference->getCookie(), - 'pp' => "test2", - 'user' => "Doe", - 'role' => "Athlète", - 'friendship' => [], - 'analyzes' => [], - 'mails' => [], - 'users' => [], - 'infoUser' => [], - 'exos' => [], - 'member' => [] - ]); - } - - #[Route(path: '/profile', name: 'profile', methods: ['GET'])] - public function profile(): Response - { - return $this->render('./page/profile.html.twig',[ - 'css' => $this->preference->getCookie(), - 'pp' => "test2", - 'user' => "Doe", - 'role' => "Athlète", - 'friendship' => [], - 'analyzes' => [], - 'mails' => [], - 'users' => [], - 'infoUser' => [], - 'exos' => [], - 'member' => [] - ]); - } - - #[Route(path: '/preferences', name: 'preferences', methods: ['POST'])] - public function preferences(string $theme, IRequest $req): Response - { - /*TODO*/ - - // VALIDER LES DONNEES - $this->preference->majCookie($theme); + // #[Route(path: '/coaching', name: 'coaching', methods: ['GET'])] + // public function coaching(): Response + // { + // return $this->render('./page/coaching.html.twig',[ + // 'css' => $this->preference->getCookie(), + // 'pp' => "test2", + // 'user' => "Doe", + // 'role' => "Athlète", + // 'friendship' => [], + // 'analyzes' => [], + // 'mails' => [], + // 'users' => [], + // 'infoUser' => [], + // 'exos' => [], + // 'member' => [] + // ]); + // } + + // #[Route(path: '/mail', name: 'mail', methods: ['GET'])] + // public function mail(): Response + // { + // return $this->render('./page/mail.html.twig',[ + // 'css' => $this->preference->getCookie(), + // 'pp' => "test2", + // 'user' => "Doe", + // 'role' => "Athlète", + // 'friendship' => [], + // 'analyzes' => [], + // 'mails' => [], + // 'users' => [], + // 'infoUser' => [], + // 'exos' => [], + // 'member' => [] + // ]); + // } + + // #[Route(path: '/import', name: 'import', methods: ['GET'])] + // public function import(): Response + // { + // return $this->render('./page/import.html.twig',[ + // 'css' => $this->preference->getCookie(), + // 'pp' => "test2", + // 'user' => "Doe", + // 'role' => "Athlète", + // 'friendship' => [], + // 'analyzes' => [], + // 'mails' => [], + // 'users' => [], + // 'infoUser' => [], + // 'exos' => [], + // 'member' => [] + // ]); + // } + + // #[Route(path: '/settings', name: 'settings', methods: ['GET'])] + // public function settings(IRequest $req): Response + // { + // return $this->render('./page/settings.html.twig',[ + // 'css' => $this->preference->getCookie(), + // 'pp' => "test2", + // 'user' => "Doe", + // 'role' => "Athlète", + // 'friendship' => [], + // 'analyzes' => [], + // 'mails' => [], + // 'users' => [], + // 'infoUser' => [], + // 'exos' => [], + // 'member' => [] + // ]); + // } + + // #[Route(path: '/profile', name: 'profile', methods: ['GET'])] + // public function profile(): Response + // { + // return $this->render('./page/profile.html.twig',[ + // 'css' => $this->preference->getCookie(), + // 'pp' => "test2", + // 'user' => "Doe", + // 'role' => "Athlète", + // 'friendship' => [], + // 'analyzes' => [], + // 'mails' => [], + // 'users' => [], + // 'infoUser' => [], + // 'exos' => [], + // 'member' => [] + // ]); + // } + + // #[Route(path: '/preferences', name: 'preferences', methods: ['POST'])] + // public function preferences(string $theme, IRequest $req): Response + // { + // /*TODO*/ + + // // VALIDER LES DONNEES + // $this->preference->majCookie($theme); - return $this->render('./page/settings.html.twig',[ - 'css' => $this->preference->getCookie(), - 'pp' => "test2", - 'user' => "Doe", - 'role' => "Athlète", - 'friendship' => [], - 'analyzes' => [], - 'mails' => [], - 'users' => [], - 'infoUser' => [], - 'exos' => [], - 'member' => [] - ]); - } - - #[Route(path: '/psettings', name: 'psettings', methods: ['POST'])] - public function psettings(string $nom,string $prenom,string $dateNaissance,string $mail,string $tel, IRequest $req): Response - { + // return $this->render('./page/settings.html.twig',[ + // 'css' => $this->preference->getCookie(), + // 'pp' => "test2", + // 'user' => "Doe", + // 'role' => "Athlète", + // 'friendship' => [], + // 'analyzes' => [], + // 'mails' => [], + // 'users' => [], + // 'infoUser' => [], + // 'exos' => [], + // 'member' => [] + // ]); + // } + + // #[Route(path: '/psettings', name: 'psettings', methods: ['POST'])] + // public function psettings(string $nom,string $prenom,string $dateNaissance,string $mail,string $tel, IRequest $req): Response + // { - return $this->render('./page/settings.html.twig',[ - 'css' => $this->preference->getCookie(), - 'pp' => "test2", - 'user' => $prenom, - 'role' => "Athlète", - 'friendship' => [], - 'analyzes' => [], - 'mails' => [], - 'users' => [], - 'infoUser' => [], - 'exos' => [], - 'member' => [] - ]); - } - - #[Route(path: '/mdp', name: 'mdp', methods: ['POST'])] - public function mdp(string $ancienMotDePasse,string $nouveauMotDePasse,string $confirmerMotDePasse, IRequest $req): Response - { + // return $this->render('./page/settings.html.twig',[ + // 'css' => $this->preference->getCookie(), + // 'pp' => "test2", + // 'user' => $prenom, + // 'role' => "Athlète", + // 'friendship' => [], + // 'analyzes' => [], + // 'mails' => [], + // 'users' => [], + // 'infoUser' => [], + // 'exos' => [], + // 'member' => [] + // ]); + // } + + // #[Route(path: '/mdp', name: 'mdp', methods: ['POST'])] + // public function mdp(string $ancienMotDePasse,string $nouveauMotDePasse,string $confirmerMotDePasse, IRequest $req): Response + // { - // CONFIRMER LES DONNESS !!!!! IMPORTANT - - return $this->render('./page/settings.html.twig',[ - 'css' => $this->preference->getCookie(), - 'pp' => "test2", - 'user' => "Doe", - 'role' => "Athlète", - 'friendship' => [], - 'analyzes' => [], - 'mails' => [], - 'users' => [], - 'infoUser' => [], - 'exos' => [], - 'member' => [] - ]); - } - - #[Route(path: '/login', name: 'login', methods: ['POST'])] - public function login(string $username,string $mdp, IRequest $req): Response - { + // // CONFIRMER LES DONNESS !!!!! IMPORTANT + + // return $this->render('./page/settings.html.twig',[ + // 'css' => $this->preference->getCookie(), + // 'pp' => "test2", + // 'user' => "Doe", + // 'role' => "Athlète", + // 'friendship' => [], + // 'analyzes' => [], + // 'mails' => [], + // 'users' => [], + // 'infoUser' => [], + // 'exos' => [], + // 'member' => [] + // ]); + // } + + // #[Route(path: '/login', name: 'login', methods: ['POST'])] + // public function login(string $username,string $mdp, IRequest $req): Response + // { - // CONFIRMER LES DONNESS !!!!! IMPORTANT - - return $this->render('./page/home.html.twig',[ - 'css' => $this->preference->getCookie(), - 'pp' => "test2", - 'user' => "Doe", - 'role' => "Athlète", - 'friendship' => [], - 'analyzes' => [], - 'mails' => [], - 'users' => [], - 'infoUser' => [], - 'exos' => [], - 'member' => [] - ]); - } + // // CONFIRMER LES DONNESS !!!!! IMPORTANT + + // return $this->render('./page/home.html.twig',[ + // 'css' => $this->preference->getCookie(), + // 'pp' => "test2", + // 'user' => "Doe", + // 'role' => "Athlète", + // 'friendship' => [], + // 'analyzes' => [], + // 'mails' => [], + // 'users' => [], + // 'infoUser' => [], + // 'exos' => [], + // 'member' => [] + // ]); + // } #[Route(path: '/log', name: 'log', methods: ['GET'])] public function login2(): Response @@ -653,17 +653,7 @@ class Controller extends BaseController // CONFIRMER LES DONNESS !!!!! IMPORTANT return $this->render('./page/home.html.twig',[ - 'css' => $this->preference->getCookie(), - 'pp' => "test2", - 'user' => "Doe", - 'role' => "Athlète", - 'friendship' => [], - 'analyzes' => [], - 'mails' => [], - 'users' => [], - 'infoUser' => [], - 'exos' => [], - 'member' => [] + 'css' => $this->preference->getCookie() ]); } @@ -674,61 +664,51 @@ class Controller extends BaseController // CONFIRMER LES DONNESS !!!!! IMPORTANT return $this->render('./page/register.html.twig',[ - 'css' => $this->preference->getCookie(), - 'pp' => "test2", - 'user' => "Doe", - 'role' => "Athlète", - 'friendship' => [], - 'analyzes' => [], - 'mails' => [], - 'users' => [], - 'infoUser' => [], - 'exos' => [], - 'member' => [] + 'css' => $this->preference->getCookie() ]); } - #[Route(path: '/pass', name: 'pass', methods: ['GET'])] - public function pass(): Response - { + // #[Route(path: '/pass', name: 'pass', methods: ['GET'])] + // public function pass(): Response + // { - // CONFIRMER LES DONNESS !!!!! IMPORTANT - - return $this->render('./page/password.html.twig',[ - 'css' => $this->preference->getCookie(), - 'pp' => "test2", - 'user' => "Doe", - 'role' => "Athlète", - 'friendship' => [], - 'analyzes' => [], - 'mails' => [], - 'users' => [], - 'infoUser' => [], - 'exos' => [], - 'member' => [] - ]); - } - - #[Route(path: '/password', name: 'password', methods: ['POST'])] - public function password(string $email, IRequest $req): Response - { + // // CONFIRMER LES DONNESS !!!!! IMPORTANT + + // return $this->render('./page/password.html.twig',[ + // 'css' => $this->preference->getCookie(), + // 'pp' => "test2", + // 'user' => "Doe", + // 'role' => "Athlète", + // 'friendship' => [], + // 'analyzes' => [], + // 'mails' => [], + // 'users' => [], + // 'infoUser' => [], + // 'exos' => [], + // 'member' => [] + // ]); + // } + + // #[Route(path: '/password', name: 'password', methods: ['POST'])] + // public function password(string $email, IRequest $req): Response + // { - // CONFIRMER LES DONNESS !!!!! IMPORTANT - - return $this->render('./page/login.html.twig',[ - 'css' => $this->preference->getCookie(), - 'pp' => "test2", - 'user' => "Doe", - 'role' => "Athlète", - 'friendship' => [], - 'analyzes' => [], - 'mails' => [], - 'users' => [], - 'infoUser' => [], - 'exos' => [], - 'member' => [] - ]); - } + // // CONFIRMER LES DONNESS !!!!! IMPORTANT + + // return $this->render('./page/login.html.twig',[ + // 'css' => $this->preference->getCookie(), + // 'pp' => "test2", + // 'user' => "Doe", + // 'role' => "Athlète", + // 'friendship' => [], + // 'analyzes' => [], + // 'mails' => [], + // 'users' => [], + // 'infoUser' => [], + // 'exos' => [], + // 'member' => [] + // ]); + // } } diff --git a/Sources/src/app/controller/HeartRateController.php b/Sources/src/app/controller/HeartRateController.php index 66509bf8..0c5163a5 100644 --- a/Sources/src/app/controller/HeartRateController.php +++ b/Sources/src/app/controller/HeartRateController.php @@ -1,36 +1,45 @@ render('./page/import.html.twig',[ -// 'css' => $this->preference->getCookie(), -// 'pp' => "test2", -// 'user' => "Doe", -// 'role' => "Athlète", -// 'friendship' => [], -// 'analyzes' => [], -// 'mails' => [], -// 'users' => [], -// 'infoUser' => [], -// 'exos' => [], -// 'member' => [] -// ]); -// } +namespace App\Controller; + +use App\Container; +use App\Router\Request\IRequest; +use App\Router\Response\Response; +use Shared\Attributes\Route; +use Twig\Environment; +use Data\Core\Preferences; +use Shared\Log; + +class HeartRateController extends BaseController +{ + + private Environment $twig; + private Preferences $preference; + + public function __construct() + { + session_start(); + $this->preference = new Preferences(); + } + + + #[Route(path: '/import', name: 'import', methods: ['GET'])] + public function import(): Response + { + return $this->render('./page/import.html.twig',[ + 'css' => $this->preference->getCookie(), + 'pp' => "test2", + 'user' => "Doe", + 'role' => "Athlète", + 'friendship' => [], + 'analyzes' => [], + 'mails' => [], + 'users' => [], + 'infoUser' => [], + 'exos' => [], + 'member' => [] + ]); + } -// } \ No newline at end of file +} \ No newline at end of file diff --git a/Sources/src/app/controller/SocialController.php b/Sources/src/app/controller/SocialController.php index 57fe43b8..b04a320c 100644 --- a/Sources/src/app/controller/SocialController.php +++ b/Sources/src/app/controller/SocialController.php @@ -1,4 +1,29 @@ - + } + + +} \ No newline at end of file diff --git a/Sources/src/app/controller/UserController.php b/Sources/src/app/controller/UserController.php index ff363560..1278376a 100644 --- a/Sources/src/app/controller/UserController.php +++ b/Sources/src/app/controller/UserController.php @@ -1,80 +1,163 @@ render('./page/home.html.twig',[ -// 'css' => $this->preference->getCookie(), -// 'pp' => "test2", -// 'user' => "Doe", -// 'role' => "Athlète", -// 'friendship' => [], -// 'analyzes' => [], -// 'mails' => [], -// 'users' => [], -// 'infoUser' => [], -// 'exos' => [], -// 'member' => [] -// ]); -// } - - -// #[Route(path: '/settings', name: 'settings', methods: ['GET'])] -// public function settings(IRequest $req): Response -// { -// return $this->render('./page/settings.html.twig',[ -// 'css' => $this->preference->getCookie(), -// 'pp' => "test2", -// 'user' => "Doe", -// 'role' => "Athlète", -// 'friendship' => [], -// 'analyzes' => [], -// 'mails' => [], -// 'users' => [], -// 'infoUser' => [], -// 'exos' => [], -// 'member' => [] -// ]); -// } - - -// #[Route(path: '/preferences', name: 'preferences', methods: ['POST'])] -// public function preferences(string $theme, IRequest $req): Response -// { -// /*TODO*/ - -// // VALIDER LES DONNEES -// $this->preference->majCookie($theme); +namespace App\Controller; + +use App\Container; +use App\Router\Request\IRequest; +use App\Router\Response\Response; +use Shared\Attributes\Route; +use Twig\Environment; +use Data\Core\Preferences; +use Shared\Log; + +class UserController extends BaseController +{ + + private Environment $twig; + private Preferences $preference; + + public function __construct() + { + session_start(); + $this->preference = new Preferences(); + } + + + #[Route(path: '/', name: 'index', methods: ['GET'])] + public function index(): Response + { + return $this->render('./page/index.html',[ + 'css' => $this->preference->getCookie(), + 'pp' => "test2", + 'user' => "Doe", + 'role' => "Athlète", + 'friendship' => [], + 'analyzes' => [], + 'mails' => [], + 'users' => [], + 'infoUser' => [], + 'exos' => [], + 'member' => [] + ]); + } + + #[Route(path: '/home', name: 'home', methods: ['GET'])] + public function home(): Response + { + return $this->render('./page/home.html.twig',[ + 'css' => $this->preference->getCookie(), + 'pp' => "test2", + 'user' => "Doe", + 'role' => "Athlète", + 'friendship' => [], + 'analyzes' => [], + 'mails' => [], + 'users' => [], + 'infoUser' => [], + 'exos' => [], + 'member' => [] + ]); + } + + + #[Route(path: '/settings', name: 'settings', methods: ['GET'])] + public function settings(IRequest $req): Response + { + return $this->render('./page/settings.html.twig',[ + 'css' => $this->preference->getCookie(), + 'pp' => "test2", + 'user' => "Doe", + 'role' => "Athlète", + 'friendship' => [], + 'analyzes' => [], + 'mails' => [], + 'users' => [], + 'infoUser' => [], + 'exos' => [], + 'member' => [] + ]); + } + + #[Route(path: '/profile', name: 'profile', methods: ['GET'])] + public function profile(): Response + { + return $this->render('./page/profile.html.twig',[ + 'css' => $this->preference->getCookie(), + 'pp' => "test2", + 'user' => "Doe", + 'role' => "Athlète", + 'friendship' => [], + 'analyzes' => [], + 'mails' => [], + 'users' => [], + 'infoUser' => [], + 'exos' => [], + 'member' => [] + ]); + } + + #[Route(path: '/preferences', name: 'preferences', methods: ['POST'])] + public function preferences(string $theme, IRequest $req): Response + { + /*TODO*/ + + // VALIDER LES DONNEES + $this->preference->majCookie($theme); -// return $this->render('./page/settings.html.twig',[ -// 'css' => $this->preference->getCookie(), -// 'pp' => "test2", -// 'user' => "Doe", -// 'role' => "Athlète", -// 'friendship' => [], -// 'analyzes' => [], -// 'mails' => [], -// 'users' => [], -// 'infoUser' => [], -// 'exos' => [], -// 'member' => [] -// ]); -// } + return $this->render('./page/settings.html.twig',[ + 'css' => $this->preference->getCookie(), + 'pp' => "test2", + 'user' => "Doe", + 'role' => "Athlète", + 'friendship' => [], + 'analyzes' => [], + 'mails' => [], + 'users' => [], + 'infoUser' => [], + 'exos' => [], + 'member' => [] + ]); + } + + #[Route(path: '/psettings', name: 'psettings', methods: ['POST'])] + public function psettings(string $nom,string $prenom,string $dateNaissance,string $mail,string $tel, IRequest $req): Response + { + + + return $this->render('./page/settings.html.twig',[ + 'css' => $this->preference->getCookie(), + 'pp' => "test2", + 'user' => $prenom, + 'role' => "Athlète", + 'friendship' => [], + 'analyzes' => [], + 'mails' => [], + 'users' => [], + 'infoUser' => [], + 'exos' => [], + 'member' => [] + ]); + } + + #[Route(path: '/mdp', name: 'mdp', methods: ['POST'])] + public function mdp(string $ancienMotDePasse,string $nouveauMotDePasse,string $confirmerMotDePasse, IRequest $req): Response + { + + // CONFIRMER LES DONNESS !!!!! IMPORTANT + + return $this->render('./page/settings.html.twig',[ + 'css' => $this->preference->getCookie(), + 'pp' => "test2", + 'user' => "Doe", + 'role' => "Athlète", + 'friendship' => [], + 'analyzes' => [], + 'mails' => [], + 'users' => [], + 'infoUser' => [], + 'exos' => [], + 'member' => [] + ]); + } -// } \ No newline at end of file +} \ No newline at end of file