diff --git a/src/app/controllers/app/app_controller.php b/src/app/controllers/app/app_controller.php index 5c8d734c32d1b6d8a47921335bfa6d68faed11e2..ed709614e75fb4ee6c9d51ebd9fc8c3dbfdf7edd 100644 --- a/src/app/controllers/app/app_controller.php +++ b/src/app/controllers/app/app_controller.php @@ -7,11 +7,11 @@ class AppController // Session validation session_start(); - if (isset($_SESSION["is_premium"]) && $_SESSION["is_premium"]) { - http_response_code(403); - header("Location: http://localhost:5173"); - return; - } + // if (isset($_SESSION["is_premium"]) && $_SESSION["is_premium"]) { + // http_response_code(403); + // header("Location: http://localhost:5173"); + // return; + // } if (!isset($_SESSION["user_id"])) { session_destroy(); diff --git a/src/app/controllers/login/post_login.php b/src/app/controllers/login/post_login.php index 7a54b65eddcf81c3429f032464d329746adb8b5c..3313dd01942ab091ed23ac9c3c26968a38f30d06 100644 --- a/src/app/controllers/login/post_login.php +++ b/src/app/controllers/login/post_login.php @@ -23,7 +23,7 @@ class PostLoginController } else { if (password_verify($password, $user['password'])) { $_SESSION["start"] = time(); - $_SESSION["expire"] = time() + 60 * 5; + $_SESSION["expire"] = time() + 60 * 1000; $_SESSION["user_id"] = $user['id_user']; if ($username == "premium") { diff --git a/src/app/controllers/profile/get_profile.php b/src/app/controllers/profile/get_profile.php new file mode 100644 index 0000000000000000000000000000000000000000..755ce3d3d0b751d755bfe99aeb31e08eb2f02509 --- /dev/null +++ b/src/app/controllers/profile/get_profile.php @@ -0,0 +1,40 @@ +<?php + +class getProfileController +{ + public function call() + { + require_once __DIR__ . "/../../views/login/login.php"; + session_start(); + // print_r($_SESSION); + // if (isset($_SESSION['user_id'])) { + $user_id = "4"; + // if (isset($_GET["user_id"])) { + // $user_id = $_GET["user_id"]; + // } + + $userModel = new UserModel(); + $profile = $userModel->getUserInfo(4); + + $data = [ + "name" => $profile->name, + "username" => $profile->username, + "url_profpic" => $profile->url_profpic, + "is_admin" => $profile->is_admin, + ]; + header("Access-Control-Allow-Origin: http://localhost:3000"); + header("Access-Control-Allow-Credentials: true"); + header("Max-Age: 86400"); + header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS"); + // header("Access-Control-Allow-Headers: $_SERVER[HTTP_ACCESS_CONTROL_REQUEST_HEADERS]"); + echo json_encode($data); + // } else { + // session_destroy(); + + // http_response_code(403); + // header("Location: " . BASE_URL . "/login"); + + // return; + // } + } +} \ No newline at end of file diff --git a/src/app/core/app.php b/src/app/core/app.php index 4da6d4e6b28b502bbd51282b488c21e6c4a2e40e..2b08fb582639226cf9a8473a3ebd4a10d5c8708f 100644 --- a/src/app/core/app.php +++ b/src/app/core/app.php @@ -7,6 +7,8 @@ class App $url = $this->parseURL(); $router = new Router(); + $router->get("public/profile", new getProfileController()); + $router->get("public", new AppController()); $router->get("public/home", new AppController()); $router->get("public/search", new AppController()); diff --git a/src/app/init.php b/src/app/init.php index 21ccb491f84af93bf4c16c6a002cec764273b130..c83fbbbbecf2eb21b94e1c426cf7e6526e30e3a6 100644 --- a/src/app/init.php +++ b/src/app/init.php @@ -39,6 +39,7 @@ require_once __DIR__ . "/controllers/library/get_library.php"; require_once __DIR__ . "/controllers/signup/get_signup.php"; require_once __DIR__ . "/controllers/signup/post_signup.php"; require_once __DIR__ . "/controllers/search/get_search.php"; +require_once __DIR__ . "/controllers/profile/get_profile.php"; require_once __DIR__ . "/controllers/app/app_controller.php";