Skip to content

Commit

Permalink
Confirmation for logout
Browse files Browse the repository at this point in the history
  • Loading branch information
SuchitReddi committed Nov 29, 2023
1 parent 4d74768 commit c5ed37e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
6 changes: 3 additions & 3 deletions delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</body>
</html>";

// Function to validate the password (replace with your actual validation logic)
// Function to validate the password
function validatePassword($currentuser, $enteredPassword) {
//$enteredPassword = password_hash($enteredPassword, PASSWORD_DEFAULT); // More secure way.
$enteredPassword = stripslashes($enteredPassword);
Expand All @@ -55,7 +55,7 @@ function validatePassword($currentuser, $enteredPassword) {
if ($result && mysqli_num_rows($result) != 0) {
$row = mysqli_fetch_assoc($result);
$hashedPassword = $row['password'];
// Example: Check against the stored hashed password in the database
// Check against the stored hashed password in the database
if ($hashedPassword === $enteredPassword) {
return true;
}
Expand All @@ -70,7 +70,7 @@ function validatePassword($currentuser, $enteredPassword) {
// Check if the form is submitted
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (isset($_POST['delete_confirm'])) {
$enteredPassword = $_POST['password']; // Assuming your form has an input named 'password'
$enteredPassword = $_POST['password'];

// Validate the password
if (validatePassword($currentuser, $enteredPassword)) {
Expand Down
4 changes: 2 additions & 2 deletions logout.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
sentinelPageStartup( array( ) );

if( !sentinelIsLoggedIn() ) { // The user shouldn't even be on this page
// sentinelMessagePush( "You were not logged in" );
sentinelMessagePush( "Please login or signup" );
sentinelRedirect( 'login.php' );
}

sentinelLogout();
sentinelMessagePush( "You have logged out" );
sentinelMessagePush( "You have been logged out" );
sentinelRedirect( 'login.php' );

?>
10 changes: 9 additions & 1 deletion sentinel/includes/sentinelPage.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,14 @@ function confirmDelete() {
// Perform the delete action if confirmed
window.location.href = \"/cybersentinel/delete.php\"; // Replace with your actual delete action
}
}
function confirmLogout() {
var currentuser = \"" . sentinelCurrentUser() . "\";
if (confirm(\"'\" + currentuser + \"', are you sure you want to logout?\")) {
// Logout the user if confirmed
window.location.href = \"/cybersentinel/logout.php\"; // Replace with your
}
}
</script>
Expand Down Expand Up @@ -419,7 +427,7 @@ function confirmDelete() {
<li class=\"\"><a href=\"/cybersentinel/phpinfo.php\">PHP Info</a></li>
<li class=\"\"><a href=\"/cybersentinel/logs.php\">Logs</a></li>
<li class=\"\"><a href=\"/cybersentinel/about.php\">About</a></li>
<li class=\"\"><a href=\"/cybersentinel/logout.php\">Logout</a></li>
<li class=\"\"><a href=\"#\" onclick=\"confirmLogout()\">Logout</a></li>
<li class=\"\"><a href=\"#\" onclick=\"confirmDelete()\">Delete User</a></li>
</ul>
</div><!-- main_menu_padded div end-->
Expand Down

0 comments on commit c5ed37e

Please sign in to comment.