From f0faa9b2d2ce8ffe209f19fc1cc014b9b5df3167 Mon Sep 17 00:00:00 2001 From: samuel Date: Tue, 5 Dec 2023 18:07:49 +0100 Subject: [PATCH 1/2] deconnection and fix connection --- front/views/Editor.tsx | 19 +++++----- front/views/NewTacticPanel.tsx | 17 +++++---- public/index.php | 2 + src/App/Controller/EditorController.php | 2 +- src/App/Controller/UserController.php | 7 ++++ src/App/Session/MutableSessionHandle.php | 2 + src/App/Session/PhpSessionHandle.php | 4 ++ src/App/Views/display_login.html.twig | 47 ++++++++++++++++-------- src/App/Views/home.twig | 1 + 9 files changed, 67 insertions(+), 34 deletions(-) diff --git a/front/views/Editor.tsx b/front/views/Editor.tsx index 14ebbf6..99e5177 100644 --- a/front/views/Editor.tsx +++ b/front/views/Editor.tsx @@ -55,12 +55,7 @@ interface RackedPlayer { key: string } -export default function Editor({ - id, - name, - courtType, - content, -}: EditorProps) { +export default function Editor({ id, name, courtType, content }: EditorProps) { const isInGuestMode = id == -1 const storage_content = localStorage.getItem(GUEST_MODE_CONTENT_STORAGE_KEY) @@ -68,11 +63,16 @@ export default function Editor({ isInGuestMode && storage_content != null ? storage_content : content const storage_name = localStorage.getItem(GUEST_MODE_TITLE_STORAGE_KEY) - const editorName = isInGuestMode && storage_name != null ? storage_name : name + const editorName = + isInGuestMode && storage_name != null ? storage_name : name return ( { if (isInGuestMode) { localStorage.setItem( @@ -94,7 +94,8 @@ export default function Editor({ (r) => r.ok, ) }} - courtType={courtType}/> + courtType={courtType} + /> ) } diff --git a/front/views/NewTacticPanel.tsx b/front/views/NewTacticPanel.tsx index d3d5528..bd9badb 100644 --- a/front/views/NewTacticPanel.tsx +++ b/front/views/NewTacticPanel.tsx @@ -3,7 +3,7 @@ import "../style/new_tactic_panel.css" import plainCourt from "../assets/court/court.svg" import halfCourt from "../assets/court/half_court.svg" -import {BASE} from "../Constants"; +import { BASE } from "../Constants" export default function NewTacticPanel() { return ( @@ -32,11 +32,11 @@ export default function NewTacticPanel() { } function CourtKindButton({ - name, - image, - details, - redirect, - }: { + name, + image, + details, + redirect, +}: { name: string image: string details: string @@ -45,14 +45,15 @@ function CourtKindButton({ return (
location.href = BASE + redirect}> + onClick={() => (location.href = BASE + redirect)}>
{details}
{name} + className="court-kind-button-image" + />
diff --git a/public/index.php b/public/index.php index cd777ab..8c9a62b 100644 --- a/public/index.php +++ b/public/index.php @@ -85,6 +85,8 @@ function getRoutes(): AltoRouter { $ar->map("GET", "/", Action::auth(fn(SessionHandle $s) => getUserController()->home($s))); $ar->map("GET", "/home", Action::auth(fn(SessionHandle $s) => getUserController()->home($s))); $ar->map("GET", "/settings", Action::auth(fn(SessionHandle $s) => getUserController()->settings($s))); + $ar->map("GET", "/disconnect", Action::auth(fn(MutableSessionHandle $s) => getUserController()->disconnect($s))); + //tactic-related $ar->map("GET", "/tactic/[i:id]/view", Action::auth(fn(int $id, SessionHandle $s) => getVisualizerController()->openVisualizer($id, $s))); diff --git a/src/App/Controller/EditorController.php b/src/App/Controller/EditorController.php index 855d8d9..3bbbe61 100644 --- a/src/App/Controller/EditorController.php +++ b/src/App/Controller/EditorController.php @@ -43,7 +43,7 @@ class EditorController { "id" => -1, //-1 id means that the editor will not support saves "name" => TacticModel::TACTIC_DEFAULT_NAME, "content" => '{"players": []}', - "courtType" => $courtType->name() + "courtType" => $courtType->name(), ]); } diff --git a/src/App/Controller/UserController.php b/src/App/Controller/UserController.php index d6f9f89..5ce1318 100644 --- a/src/App/Controller/UserController.php +++ b/src/App/Controller/UserController.php @@ -2,8 +2,10 @@ namespace IQBall\App\Controller; +use IQBall\App\Session\MutableSessionHandle; use IQBall\App\Session\SessionHandle; use IQBall\App\ViewHttpResponse; +use IQBall\Core\Http\HttpResponse; use IQBall\Core\Model\TacticModel; class UserController { @@ -33,4 +35,9 @@ class UserController { return ViewHttpResponse::twig("account_settings.twig", []); } + public function disconnect(MutableSessionHandle $session): HttpResponse { + $session->destroy(); + return HttpResponse::redirect("/"); + } + } diff --git a/src/App/Session/MutableSessionHandle.php b/src/App/Session/MutableSessionHandle.php index 9ef23c0..14871b6 100644 --- a/src/App/Session/MutableSessionHandle.php +++ b/src/App/Session/MutableSessionHandle.php @@ -17,4 +17,6 @@ interface MutableSessionHandle extends SessionHandle { * @param Account $account update the session's account */ public function setAccount(Account $account): void; + + public function destroy(): void; } diff --git a/src/App/Session/PhpSessionHandle.php b/src/App/Session/PhpSessionHandle.php index 9a08e47..cea20a6 100644 --- a/src/App/Session/PhpSessionHandle.php +++ b/src/App/Session/PhpSessionHandle.php @@ -31,4 +31,8 @@ class PhpSessionHandle implements MutableSessionHandle { public function setInitialTarget(?string $url): void { $_SESSION["target"] = $url; } + + public function destroy(): void { + session_destroy(); + } } diff --git a/src/App/Views/display_login.html.twig b/src/App/Views/display_login.html.twig index cdc11a5..8b61da1 100644 --- a/src/App/Views/display_login.html.twig +++ b/src/App/Views/display_login.html.twig @@ -40,18 +40,6 @@ border-radius: 5px; } - input[type="submit"] { - background-color: #007bff; - color: #fff; - padding: 10px 20px; - border: none; - border-radius: 5px; - cursor: pointer; - } - - input[type="submit"]:hover { - background-color: #0056b3; - } .error-messages { color: #ff331a; @@ -68,6 +56,32 @@ ; } {% endfor %} + + .inscr{ + font-size: small; + text-align: right; + } + + #buttons{ + display: flex; + justify-content: space-between; + padding: 10px 20px; + + } + + .button{ + background-color: #007bff; + color: #fff; + padding: 10px 20px; + border: none; + border-radius: 5px; + cursor: pointer; + } + + .button:hover{ + background-color: #0056b3; + } +
@@ -82,11 +96,12 @@ - - +

+

Vous n'avez pas de compte ?

-
- +
+ +
diff --git a/src/App/Views/home.twig b/src/App/Views/home.twig index 5d9e8ae..7d8430e 100644 --- a/src/App/Views/home.twig +++ b/src/App/Views/home.twig @@ -50,6 +50,7 @@ +

IQ Ball

-- 2.36.3 From b81346e31c01dff992c288a26303bf558b6dd715 Mon Sep 17 00:00:00 2001 From: samuel Date: Tue, 5 Dec 2023 18:27:26 +0100 Subject: [PATCH 2/2] add login from register --- src/App/Views/display_login.html.twig | 2 +- src/App/Views/display_register.html.twig | 44 ++++++++++++++++-------- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/src/App/Views/display_login.html.twig b/src/App/Views/display_login.html.twig index 8b61da1..a9fe349 100644 --- a/src/App/Views/display_login.html.twig +++ b/src/App/Views/display_login.html.twig @@ -96,7 +96,7 @@ -

+

Vous n'avez pas de compte ?

diff --git a/src/App/Views/display_register.html.twig b/src/App/Views/display_register.html.twig index 8649de8..bd17ec6 100644 --- a/src/App/Views/display_register.html.twig +++ b/src/App/Views/display_register.html.twig @@ -40,23 +40,11 @@ border-radius: 5px; } - input[type="submit"] { - background-color: #007bff; - color: #fff; - padding: 10px 20px; - border: none; - border-radius: 5px; - cursor: pointer; - } - .error-messages { color: #ff331a; font-style: italic; } - input[type="submit"]:hover { - background-color: #0056b3; - } {% for err in fails %} .form-group @@ -69,6 +57,31 @@ } {% endfor %} + .inscr{ + font-size: small; + text-align: right; + } + + #buttons{ + display: flex; + justify-content: space-between; + padding: 10px 20px; + + } + + .button{ + background-color: #007bff; + color: #fff; + padding: 10px 20px; + border: none; + border-radius: 5px; + cursor: pointer; + } + + .button:hover{ + background-color: #0056b3; + } + @@ -87,12 +100,13 @@ - +

Vous avez déja un compte ?

-
- +
+ +
-- 2.36.3