mirror of
https://github.com/delight-im/PHP-Auth.git
synced 2025-08-03 22:57:27 +02:00
Add tests for method 'getRolesForUserById' from class 'Administration'
This commit is contained in:
@@ -523,6 +523,19 @@ function processRequestData(\Delight\Auth\Auth $auth) {
|
|||||||
return 'ID required';
|
return 'ID required';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if ($_POST['action'] === 'admin.getRoles') {
|
||||||
|
if (isset($_POST['id'])) {
|
||||||
|
try {
|
||||||
|
return $auth->admin()->getRolesForUserById($_POST['id']);
|
||||||
|
}
|
||||||
|
catch (\Delight\Auth\UnknownIdException $e) {
|
||||||
|
return 'unknown ID';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return 'ID required';
|
||||||
|
}
|
||||||
|
}
|
||||||
else if ($_POST['action'] === 'admin.logInAsUserById') {
|
else if ($_POST['action'] === 'admin.logInAsUserById') {
|
||||||
if (isset($_POST['id'])) {
|
if (isset($_POST['id'])) {
|
||||||
try {
|
try {
|
||||||
@@ -880,6 +893,12 @@ function showGuestUserForm() {
|
|||||||
echo '<button type="submit">Does user have role?</button>';
|
echo '<button type="submit">Does user have role?</button>';
|
||||||
echo '</form>';
|
echo '</form>';
|
||||||
|
|
||||||
|
echo '<form action="" method="post" accept-charset="utf-8">';
|
||||||
|
echo '<input type="hidden" name="action" value="admin.getRoles" />';
|
||||||
|
echo '<input type="text" name="id" placeholder="ID" /> ';
|
||||||
|
echo '<button type="submit">Get user\'s roles</button>';
|
||||||
|
echo '</form>';
|
||||||
|
|
||||||
echo '<form action="" method="post" accept-charset="utf-8">';
|
echo '<form action="" method="post" accept-charset="utf-8">';
|
||||||
echo '<input type="hidden" name="action" value="admin.logInAsUserById" />';
|
echo '<input type="hidden" name="action" value="admin.logInAsUserById" />';
|
||||||
echo '<input type="text" name="id" placeholder="ID" /> ';
|
echo '<input type="text" name="id" placeholder="ID" /> ';
|
||||||
|
Reference in New Issue
Block a user