diff --git a/blokus.php b/blokus.php index 9b23392..fd1d62b 100644 --- a/blokus.php +++ b/blokus.php @@ -98,7 +98,7 @@ public function routeRequest($input) { }); $router->add('POST', 'users/logout', 'logoutUser'); // POST /users/logout -> logoutUser function $router->add('GET', 'users/session', 'checkSession'); // GET /users/session -> checkSession function -$router->add('GET', 'users/user', 'getUserProfilef'); // Mapping DELETE /accounts/{id} to deleteUser function + // Handle the request $input = json_decode(file_get_contents('php://input'), true); diff --git a/lib/users.php b/lib/users.php index ab7d805..806f470 100755 --- a/lib/users.php +++ b/lib/users.php @@ -38,7 +38,6 @@ function loginUser($username, $password) { // Compare the entered password with the stored password if ($password === $user['password']) { $_SESSION['user_id'] = $user['id']; - $_SESSION['user_name'] = $username; echo json_encode(['success' => true, 'message' => 'Login successful']); } else { echo json_encode(['success' => false, 'message' => 'Invalid username or password']); @@ -69,17 +68,6 @@ function checkSession() { } } -function isLoggedIn() { - // session_start(); - - if (isset($_SESSION['user_id'])) { - return true; - } else { - return false; - } -} - - function resetPassword($email) { try { @@ -129,25 +117,4 @@ function updatePassword($userId, $newPassword) { } } - -function getUserProfilef() { - //session_start(); - - if (isLoggedIn() == false) { - echo json_encode(['error' => 'User not logged in']); - - } - - echo json_encode(isLoggedIn()); - - - - $userId = $_SESSION['user_id']; - $userName = $_SESSION['user_name']; - - echo json_encode(['user_id' => $userId, 'user_name' => $userName]); - -} - - ?> \ No newline at end of file