From 1b18825afab97e2a6e48e6f4f5e64a27551058b4 Mon Sep 17 00:00:00 2001 From: anperederi Date: Thu, 21 Dec 2023 20:27:56 +0100 Subject: [PATCH] update merged, add .env file to resolve this --- Sources/src/app/controller/AuthController.php | 2 +- Sources/src/app/controller/Controller.php | 843 +++++++++--------- Sources/src/app/controller/UserController.php | 40 +- 3 files changed, 443 insertions(+), 442 deletions(-) diff --git a/Sources/src/app/controller/AuthController.php b/Sources/src/app/controller/AuthController.php index 92d50404..758e6e79 100644 --- a/Sources/src/app/controller/AuthController.php +++ b/Sources/src/app/controller/AuthController.php @@ -141,7 +141,7 @@ class AuthController extends BaseController } - #[Route(path: '/logout', name: 'logout', methods: ['POST'])] + #[Route(path: '/logout', name: 'logout', methods: ['GET'])] public function logout(IRequest $request): IResponse { $error = []; diff --git a/Sources/src/app/controller/Controller.php b/Sources/src/app/controller/Controller.php index e6e85493..fb2ed0fa 100644 --- a/Sources/src/app/controller/Controller.php +++ b/Sources/src/app/controller/Controller.php @@ -1,423 +1,424 @@ render('./page/activity.html.twig',[ - 'css' => $this->preference->getCookie(), - 'pp' => "test2", - 'user' => "Doe", - 'role' => "Athlète", - 'friendship' => [], - 'analyzes' => [], - 'mails' => [], - 'users' => [], - 'infoUser' => [], - 'exos' => [], - 'member' => [] - ]); - } - - - #[Route(path: '/exercices', name: 'exercices', methods: ['POST'])] // 8 - public function exercices(String $type, String $intensite, String $date, IRequest $req): Response - { - $exercicesArray = [ - [ - 'date' => $date, - 'type' => $type, - 'intensite' => $intensite, - 'status' => 'A venur', - ] - ]; - return $this->render('./page/exercice.html.twig',[ - 'css' => $this->preference->getCookie(), - 'pp' => "test2", - 'user' => "Doe", - 'role' => "Athlète", - 'friendship' => [], - 'analyzes' => [], - 'mails' => [], - 'users' => [], - 'infoUser' => [], - 'exos' => $exercicesArray, - 'member' => [] - ]); - } - - #[Route(path: '/search-user', name: 'search-user', methods: ['GET'])] - public function searchUser(string $username, IRequest $req): Response - { - $taberror = []; - // FILTER - $utiliArray = [ - [ - 'nom' => 'John', - 'prenom' => 'Doe', - 'img' => 'john_doe', - 'username' => 'johndoe', - ], - [ - 'nom' => 'Alice', - 'prenom' => 'Smith', - 'img' => 'alice_smith', - 'username' => 'alicesmith', - ], - ]; - // if(!Validation::val_string($name)){ - try { - //code... - // $model->userMgr->addFriend($name); - return $this->render('./page/addfriend.html.twig',[ - 'css' => $this->preference->getCookie(), - 'pp' => "test2", - 'user' => "Doe", - 'role' => "Athlète", - 'friendship' => [], - 'analyzes' => [], - 'mails' => [], - 'users' => $utiliArray, - 'infoUser' => [], - 'exos' => [], - 'member' => [], - 'responce' => "Notification d'ajout envoyée à $username" - ]); - } catch (\Throwable $th) { - //throw $th; - // return $this->render("addfriend.html.twig", ['tabError' => $taberror ]); - } - // } - - } - - #[Route(path: '/search-member', name: 'search-member', methods: ['GET'])] - public function searchMember(string $username, IRequest $req): Response - { - $taberror = []; - // FILTER - $utiliArray = [ - [ - 'nom' => 'John', - 'prenom' => 'Doe', - 'img' => 'john_doe', - 'username' => 'johndoe', - ], - [ - 'nom' => 'Alice', - 'prenom' => 'Smith', - 'img' => 'alice_smith', - 'username' => 'alicesmith', - ], - ]; - // if(!Validation::val_string($name)){ - try { - //code... - // $model->userMgr->addFriend($name); - return $this->render('./page/addmember.html.twig',[ - 'css' => $this->preference->getCookie(), - 'pp' => "test2", - 'user' => "Doe", - 'role' => "Athlète", - 'friendship' => [], - 'analyzes' => [], - 'mails' => [], - 'users' => $utiliArray, - 'infoUser' => [], - 'exos' => [], - 'member' => [], - 'responce' => "Notification d'ajout envoyée à $username" - ]); - } catch (\Throwable $th) { - //throw $th; - // return $this->render("addfriend.html.twig", ['tabError' => $taberror ]); - } - // } - - } - - #[Route(path: '/add-member', name: 'add-member', methods: ['POST'])] - public function addmember(string $username, IRequest $req): Response - { - $taberror = []; - $utiliArray = [ - [ - 'nom' => 'John', - 'prenom' => 'Doe', - 'img' => 'john_doe', - 'username' => 'johndoe', - ], - [ - 'nom' => 'Alice', - 'prenom' => 'Smith', - 'img' => 'alice_smith', - 'username' => 'alicesmith', - ], - ]; - // if(!Validation::val_string($name)){ - try { - //code... - // $model->userMgr->addFriend($name); - return $this->render('./page/addmember.html.twig',[ - 'css' => $this->preference->getCookie(), - 'pp' => "test2", - 'user' => "Doe", - 'role' => "Athlète", - 'friendship' => [], - 'analyzes' => [], - 'mails' => [], - 'users' => $utiliArray, - 'infoUser' => [], - 'exos' => [], - 'member' => [], - 'responce' => "Notification d'ajout envoyée à $username" - ]); - } catch (\Throwable $th) { - //throw $th; - // return $this->render("addfriend.html.twig", ['tabError' => $taberror ]); - } - // } - - } - - #[Route(path: '/member', name: 'member', methods: ['GET'])] - public function member(): Response - { - $utiliArray = [ - [ - 'nom' => 'John', - 'prenom' => 'Doe', - 'img' => 'john_doe', - 'username' => 'johndoe', - ], - [ - 'nom' => 'Alice', - 'prenom' => 'Smith', - 'img' => 'alice_smith', - 'username' => 'alicesmith', - ], - ]; - return $this->render('./page/addmember.html.twig',[ - 'css' => $this->preference->getCookie(), - 'pp' => "test2", - 'user' => "Doe", - 'role' => "Athlète", - 'friendship' => [], - 'analyzes' => [], - 'mails' => [], - 'users' => $utiliArray, - 'infoUser' => [], - 'exos' => [], - 'member' => [], - ]); - } - - - #[Route(path: '/friendlist', name: 'friendlist', methods: ['POST'])] - public function friendlist(string $username, IRequest $req): Response - { - $utiliArray = [ - [ - 'nom' => 'John', - 'prenom' => 'Doe', - 'img' => 'john_doe', - 'username' => 'johndoe', - ], - [ - 'nom' => 'Alice', - 'prenom' => 'Smith', - 'img' => 'alice_smith', - 'username' => 'alicesmith', - ], - ]; - /* TODO */ - - // -> Enlever ou bloquer un utilisateur en fonction de son username - - return $this->render('./page/friend.html.twig',[ - 'css' => $this->preference->getCookie(), - 'pp' => "test2", - 'user' => "Doe", - 'role' => "Athlète", - 'friendship' => $utiliArray, - 'analyzes' => [], - 'mails' => [], - 'users' => [], - 'infoUser' => [], - 'exos' => [], - 'member' => [], - ]); - } - - #[Route(path: '/friendlist', name: 'friendlist2', methods: ['GET'])] - public function friendlist2(): Response - { - $utiliArray = [ - [ - 'nom' => 'John', - 'prenom' => 'Doe', - 'img' => 'test', - 'status' => 'johndoe', - 'username' => 'jdoe', - ], - [ - 'nom' => 'Alice', - 'prenom' => 'Smith', - 'img' => 'test2', - 'status' => 'alicesmith', - 'username' => 'asmith', - ], - ]; - return $this->render('./page/friend.html.twig',[ - 'css' => $this->preference->getCookie(), - 'pp' => "test2", - 'user' => "Doe", - 'role' => "Athlète", - 'friendship' => $utiliArray, - '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: '/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: '/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: '/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: '/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/login.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; +// +//// TODO : Remove this BaseClass +//class Controller extends BaseController +//{ +// +// #[Route(path: '/activity', name: 'activity', methods: ['GET'])] +// public function activity(): Response +// { +// return $this->render('./page/activity.html.twig',[ +// 'css' => $this->preference->getCookie(), +// 'pp' => "test2", +// 'user' => "Doe", +// 'role' => "Athlète", +// 'friendship' => [], +// 'analyzes' => [], +// 'mails' => [], +// 'users' => [], +// 'infoUser' => [], +// 'exos' => [], +// 'member' => [] +// ]); +// } +// +// +// #[Route(path: '/exercices', name: 'exercices', methods: ['POST'])] // 8 +// public function exercices(String $type, String $intensite, String $date, IRequest $req): Response +// { +// $exercicesArray = [ +// [ +// 'date' => $date, +// 'type' => $type, +// 'intensite' => $intensite, +// 'status' => 'A venur', +// ] +// ]; +// return $this->render('./page/exercice.html.twig',[ +// 'css' => $this->preference->getCookie(), +// 'pp' => "test2", +// 'user' => "Doe", +// 'role' => "Athlète", +// 'friendship' => [], +// 'analyzes' => [], +// 'mails' => [], +// 'users' => [], +// 'infoUser' => [], +// 'exos' => $exercicesArray, +// 'member' => [] +// ]); +// } +// +// #[Route(path: '/search-user', name: 'search-user', methods: ['GET'])] +// public function searchUser(string $username, IRequest $req): Response +// { +// $taberror = []; +// // FILTER +// $utiliArray = [ +// [ +// 'nom' => 'John', +// 'prenom' => 'Doe', +// 'img' => 'john_doe', +// 'username' => 'johndoe', +// ], +// [ +// 'nom' => 'Alice', +// 'prenom' => 'Smith', +// 'img' => 'alice_smith', +// 'username' => 'alicesmith', +// ], +// ]; +// // if(!Validation::val_string($name)){ +// try { +// //code... +// // $model->userMgr->addFriend($name); +// return $this->render('./page/addfriend.html.twig',[ +// 'css' => $this->preference->getCookie(), +// 'pp' => "test2", +// 'user' => "Doe", +// 'role' => "Athlète", +// 'friendship' => [], +// 'analyzes' => [], +// 'mails' => [], +// 'users' => $utiliArray, +// 'infoUser' => [], +// 'exos' => [], +// 'member' => [], +// 'responce' => "Notification d'ajout envoyée à $username" +// ]); +// } catch (\Throwable $th) { +// //throw $th; +// // return $this->render("addfriend.html.twig", ['tabError' => $taberror ]); +// } +// // } +// +// } +// +// #[Route(path: '/search-member', name: 'search-member', methods: ['GET'])] +// public function searchMember(string $username, IRequest $req): Response +// { +// $taberror = []; +// // FILTER +// $utiliArray = [ +// [ +// 'nom' => 'John', +// 'prenom' => 'Doe', +// 'img' => 'john_doe', +// 'username' => 'johndoe', +// ], +// [ +// 'nom' => 'Alice', +// 'prenom' => 'Smith', +// 'img' => 'alice_smith', +// 'username' => 'alicesmith', +// ], +// ]; +// // if(!Validation::val_string($name)){ +// try { +// //code... +// // $model->userMgr->addFriend($name); +// return $this->render('./page/addmember.html.twig',[ +// 'css' => $this->preference->getCookie(), +// 'pp' => "test2", +// 'user' => "Doe", +// 'role' => "Athlète", +// 'friendship' => [], +// 'analyzes' => [], +// 'mails' => [], +// 'users' => $utiliArray, +// 'infoUser' => [], +// 'exos' => [], +// 'member' => [], +// 'responce' => "Notification d'ajout envoyée à $username" +// ]); +// } catch (\Throwable $th) { +// //throw $th; +// // return $this->render("addfriend.html.twig", ['tabError' => $taberror ]); +// } +// // } +// +// } +// +// #[Route(path: '/add-member', name: 'add-member', methods: ['POST'])] +// public function addmember(string $username, IRequest $req): Response +// { +// $taberror = []; +// $utiliArray = [ +// [ +// 'nom' => 'John', +// 'prenom' => 'Doe', +// 'img' => 'john_doe', +// 'username' => 'johndoe', +// ], +// [ +// 'nom' => 'Alice', +// 'prenom' => 'Smith', +// 'img' => 'alice_smith', +// 'username' => 'alicesmith', +// ], +// ]; +// // if(!Validation::val_string($name)){ +// try { +// //code... +// // $model->userMgr->addFriend($name); +// return $this->render('./page/addmember.html.twig',[ +// 'css' => $this->preference->getCookie(), +// 'pp' => "test2", +// 'user' => "Doe", +// 'role' => "Athlète", +// 'friendship' => [], +// 'analyzes' => [], +// 'mails' => [], +// 'users' => $utiliArray, +// 'infoUser' => [], +// 'exos' => [], +// 'member' => [], +// 'responce' => "Notification d'ajout envoyée à $username" +// ]); +// } catch (\Throwable $th) { +// //throw $th; +// // return $this->render("addfriend.html.twig", ['tabError' => $taberror ]); +// } +// // } +// +// } +// +// #[Route(path: '/member', name: 'member', methods: ['GET'])] +// public function member(): Response +// { +// $utiliArray = [ +// [ +// 'nom' => 'John', +// 'prenom' => 'Doe', +// 'img' => 'john_doe', +// 'username' => 'johndoe', +// ], +// [ +// 'nom' => 'Alice', +// 'prenom' => 'Smith', +// 'img' => 'alice_smith', +// 'username' => 'alicesmith', +// ], +// ]; +// return $this->render('./page/addmember.html.twig',[ +// 'css' => $this->preference->getCookie(), +// 'pp' => "test2", +// 'user' => "Doe", +// 'role' => "Athlète", +// 'friendship' => [], +// 'analyzes' => [], +// 'mails' => [], +// 'users' => $utiliArray, +// 'infoUser' => [], +// 'exos' => [], +// 'member' => [], +// ]); +// } +// +// +// #[Route(path: '/friendlist', name: 'friendlist', methods: ['POST'])] +// public function friendlist(string $username, IRequest $req): Response +// { +// $utiliArray = [ +// [ +// 'nom' => 'John', +// 'prenom' => 'Doe', +// 'img' => 'john_doe', +// 'username' => 'johndoe', +// ], +// [ +// 'nom' => 'Alice', +// 'prenom' => 'Smith', +// 'img' => 'alice_smith', +// 'username' => 'alicesmith', +// ], +// ]; +// /* TODO */ +// +// // -> Enlever ou bloquer un utilisateur en fonction de son username +// +// return $this->render('./page/friend.html.twig',[ +// 'css' => $this->preference->getCookie(), +// 'pp' => "test2", +// 'user' => "Doe", +// 'role' => "Athlète", +// 'friendship' => $utiliArray, +// 'analyzes' => [], +// 'mails' => [], +// 'users' => [], +// 'infoUser' => [], +// 'exos' => [], +// 'member' => [], +// ]); +// } +// +// #[Route(path: '/friendlist', name: 'friendlist2', methods: ['GET'])] +// public function friendlist2(): Response +// { +// $utiliArray = [ +// [ +// 'nom' => 'John', +// 'prenom' => 'Doe', +// 'img' => 'test', +// 'status' => 'johndoe', +// 'username' => 'jdoe', +// ], +// [ +// 'nom' => 'Alice', +// 'prenom' => 'Smith', +// 'img' => 'test2', +// 'status' => 'alicesmith', +// 'username' => 'asmith', +// ], +// ]; +// return $this->render('./page/friend.html.twig',[ +// 'css' => $this->preference->getCookie(), +// 'pp' => "test2", +// 'user' => "Doe", +// 'role' => "Athlète", +// 'friendship' => $utiliArray, +// '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: '/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: '/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: '/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: '/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/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/UserController.php b/Sources/src/app/controller/UserController.php index 5ebcbcef..44615f17 100644 --- a/Sources/src/app/controller/UserController.php +++ b/Sources/src/app/controller/UserController.php @@ -87,25 +87,25 @@ class UserController extends BaseController ]); } - #[Route(path: '/logout', name: 'logout', methods: ['GET'])] - public function logout(IRequest $request): IResponse - { - $error = []; - - try { - - if($this->userMgr->deconnecter()){ - return new RedirectResponse('/'); - } - else{ - $error [] = "Erreur de deconnexion. Essayez encore"; - return new RedirectResponse('/'); - } - - } catch (\Throwable $th) { - $error [] =$th->getMessage(); - return new RedirectResponse('/'); - } - } +// #[Route(path: '/logout', name: 'logout', methods: ['GET'])] +// public function logout(IRequest $request): IResponse +// { +// $error = []; +// +// try { +// +// if($this->userMgr->deconnecter()){ +// return new RedirectResponse('/'); +// } +// else{ +// $error [] = "Erreur de deconnexion. Essayez encore"; +// return new RedirectResponse('/'); +// } +// +// } catch (\Throwable $th) { +// $error [] =$th->getMessage(); +// return new RedirectResponse('/'); +// } +// } } \ No newline at end of file