Skip to content

Commit

Permalink
Merge pull request #308 from 2pisoftware/feat/logout_on_delete
Browse files Browse the repository at this point in the history
  • Loading branch information
MaddyUnderStars authored Jun 4, 2024
2 parents ae1cea8 + 30ba700 commit 66cd8e6
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions system/modules/admin/actions/userdel.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
<?php
function userdel_GET(Web $w) {
$w->pathMatch("id");
$user = AuthService::getInstance($w)->getObject("User",$w->ctx("id"));
$user = AuthService::getInstance($w)->getObject("User", $w->ctx("id"));
if ($user) {
$user->delete();
$w->msg("User ".$user->login." deleted.","/admin/users");

if ($w->session('user_id') == $w->ctx("id")) {
// We deleted our own user, force logout
$w->sessionDestroy();
$w->redirect($w->localUrl("/auth/login"));
} else {
$w->msg("User " . $user->login . " deleted.", "/admin/users");
}
} else {
$w->error("User ".$w->ctx("id")." does not exist.","/admin/users");
$w->error("User " . $w->ctx("id") . " does not exist.", "/admin/users");
}

}
}

0 comments on commit 66cd8e6

Please sign in to comment.