Skip to content
Snippets Groups Projects
Commit d9be6c8a authored by mrsyaban's avatar mrsyaban
Browse files

feat: getprofile

parent c1e21ac3
Branches
No related merge requests found
...@@ -7,11 +7,11 @@ class AppController ...@@ -7,11 +7,11 @@ class AppController
// Session validation // Session validation
session_start(); session_start();
if (isset($_SESSION["is_premium"]) && $_SESSION["is_premium"]) { // if (isset($_SESSION["is_premium"]) && $_SESSION["is_premium"]) {
http_response_code(403); // http_response_code(403);
header("Location: http://localhost:5173"); // header("Location: http://localhost:5173");
return; // return;
} // }
if (!isset($_SESSION["user_id"])) { if (!isset($_SESSION["user_id"])) {
session_destroy(); session_destroy();
......
...@@ -23,7 +23,7 @@ class PostLoginController ...@@ -23,7 +23,7 @@ class PostLoginController
} else { } else {
if (password_verify($password, $user['password'])) { if (password_verify($password, $user['password'])) {
$_SESSION["start"] = time(); $_SESSION["start"] = time();
$_SESSION["expire"] = time() + 60 * 5; $_SESSION["expire"] = time() + 60 * 1000;
$_SESSION["user_id"] = $user['id_user']; $_SESSION["user_id"] = $user['id_user'];
if ($username == "premium") { if ($username == "premium") {
......
<?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
...@@ -7,6 +7,8 @@ class App ...@@ -7,6 +7,8 @@ class App
$url = $this->parseURL(); $url = $this->parseURL();
$router = new Router(); $router = new Router();
$router->get("public/profile", new getProfileController());
$router->get("public", new AppController()); $router->get("public", new AppController());
$router->get("public/home", new AppController()); $router->get("public/home", new AppController());
$router->get("public/search", new AppController()); $router->get("public/search", new AppController());
......
...@@ -39,6 +39,7 @@ require_once __DIR__ . "/controllers/library/get_library.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/get_signup.php";
require_once __DIR__ . "/controllers/signup/post_signup.php"; require_once __DIR__ . "/controllers/signup/post_signup.php";
require_once __DIR__ . "/controllers/search/get_search.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"; require_once __DIR__ . "/controllers/app/app_controller.php";
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment