Skip to content

Commit

Permalink
testing seesions6
Browse files Browse the repository at this point in the history
  • Loading branch information
KotsiosDimis committed Dec 17, 2024
1 parent c05c154 commit ffec77b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 34 deletions.
2 changes: 1 addition & 1 deletion blokus.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
33 changes: 0 additions & 33 deletions lib/users.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand Down Expand Up @@ -69,17 +68,6 @@ function checkSession() {
}
}

function isLoggedIn() {
// session_start();

if (isset($_SESSION['user_id'])) {
return true;
} else {
return false;
}
}



function resetPassword($email) {
try {
Expand Down Expand Up @@ -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]);

}


?>

0 comments on commit ffec77b

Please sign in to comment.