From b2f15db5c2d5d34381c0b34f76b23e60ea4aab75 Mon Sep 17 00:00:00 2001 From: creme332 <65414576+creme332@users.noreply.github.com> Date: Sat, 20 Apr 2024 10:59:22 +0400 Subject: [PATCH] create an api controller for sessions endpoint --- src/controllers/api/Sessions.php | 54 ++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/controllers/api/Sessions.php diff --git a/src/controllers/api/Sessions.php b/src/controllers/api/Sessions.php new file mode 100644 index 0000000..48d559c --- /dev/null +++ b/src/controllers/api/Sessions.php @@ -0,0 +1,54 @@ +verifyPassword($password)) { + http_response_code(401); + die(); + } + + $_SESSION['admin_email'] = $email; + session_regenerate_id(); + } + + public function index(): void + { + switch ($_SERVER['REQUEST_METHOD']) { + case 'POST': + $this->handleLogin(); + break; + default: + http_response_code(400); + die(); + } + } +} \ No newline at end of file