Files
librenms-librenms/html/pages/deluser.inc.php
mcq8 c9728a1f71 refactor: Refactored authorizers to classes (#7497)
* Refactored authorizers to classes

* Merge changes for #7335

* ! fix php 5.3 incompatibility

* Update ADAuthorizationAuthorizer.php

* Fix get_user -> getUser

* Rename AuthorizerFactory to Auth, fix interface missing functions

* Add phpdocs to all interface methods and normalize the names a bit.

* Re-work auth_test.php AD bind tests to work properly with the new class.
Reflection is not the nicest tool, but I think it is appropriate here.
Handle exceptions more nicely in auth_test.php

* Restore AD getUseList fix

Not sure how it got removed

* fix auth_test.php style
2017-11-18 10:33:03 +00:00

65 lines
2.2 KiB
PHP

<?php
use LibreNMS\Authentication\Auth;
echo '<div style="margin: 10px;">';
if ($_SESSION['userlevel'] < 10 || $_SESSION['userlevel'] > 10) {
include 'includes/error-no-perm.inc.php';
} else {
echo '<h3>Delete User</h3>';
$pagetitle[] = 'Delete user';
if (Auth::get()->canManageUsers()) {
if ($vars['action'] == 'del') {
$delete_username = dbFetchCell('SELECT username FROM users WHERE user_id = ?', array($vars['id']));
if ($vars['confirm'] == 'yes') {
if (Auth::get()->deleteUser($vars['id']) >= 0) {
print_message('<div class="infobox">User "'.$delete_username.'" deleted!');
} else {
print_error('Error deleting user "'.$delete_username.'"!');
}
} else {
print_error('You have requested deletion of the user "'.$delete_username.'". This action can not be reversed.<br /><a class="btn btn-danger" href="deluser/action=del/id='.$vars['id'].'/confirm=yes">Click to confirm</a>');
}
}
// FIXME v mysql query should be replaced by authmodule
$userlist = dbFetchRows('SELECT * FROM `users`');
echo '
<form role="form" class="form-horizontal" method="GET" action="">
<input type="hidden" name="action" value="del">
<div class="form-group">
<label for="user_id" class="col-sm-2 control-label">Select User: </label>
<div class="col-sm-6">
<select id="user_id" name="id" class="form-control input-sm">
';
foreach ($userlist as $userentry) {
$i++;
echo '<option value="'.$userentry['user_id'].'">'.$userentry['username'].'</option>';
}
echo '
</select>
</div>
</div>
<div class="form-group">
<div class="col-sm-2">
</div>
<div class="col-sm-6">
<button class="btn btn-danger btn-sm">Delete User</button>
</div>
</div>
</form>
';
} else {
print_error('Authentication module does not allow user management!');
}//end if
}//end if
echo '</div>';