From cd3469c137ff1938b7d7e70293e9db5112323ba5 Mon Sep 17 00:00:00 2001 From: Marco Date: Sat, 29 Jul 2017 20:28:18 +0200 Subject: [PATCH] Add tests for checking roles for users via 'Administration' class --- tests/index.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/index.php b/tests/index.php index 24612f6..d8b216d 100644 --- a/tests/index.php +++ b/tests/index.php @@ -363,6 +363,24 @@ function processRequestData(\Delight\Auth\Auth $auth) { return 'ok'; } + else if ($_POST['action'] === 'admin.hasRole') { + if (isset($_POST['id'])) { + if (isset($_POST['role'])) { + try { + return $auth->admin()->doesUserHaveRole($_POST['id'], $_POST['role']) ? 'yes' : 'no'; + } + catch (\Delight\Auth\UnknownIdException $e) { + return 'unknown ID'; + } + } + else { + return 'role required'; + } + } + else { + return 'ID required'; + } + } else { throw new Exception('Unexpected action: '.$_POST['action']); } @@ -619,6 +637,13 @@ function showGuestUserForm() { echo ''; echo ''; echo ''; + + echo '
'; + echo ''; + echo ' '; + echo ''; + echo ''; + echo '
'; } function createRolesOptions() {