diff --git a/tests/index.php b/tests/index.php index 14f7912..5a746f6 100644 --- a/tests/index.php +++ b/tests/index.php @@ -234,6 +234,40 @@ function processRequestData(\Delight\Auth\Auth $auth) { return 'username already exists'; } } + else if ($_POST['action'] === 'admin.deleteUser') { + if (isset($_POST['id'])) { + try { + $auth->admin()->deleteUserById($_POST['id']); + } + catch (\Delight\Auth\UnknownIdException $e) { + return 'unknown ID'; + } + } + elseif (isset($_POST['email'])) { + try { + $auth->admin()->deleteUserByEmail($_POST['email']); + } + catch (\Delight\Auth\InvalidEmailException $e) { + return 'unknown email address'; + } + } + elseif (isset($_POST['username'])) { + try { + $auth->admin()->deleteUserByUsername($_POST['username']); + } + catch (\Delight\Auth\UnknownUsernameException $e) { + return 'unknown username'; + } + catch (\Delight\Auth\AmbiguousUsernameException $e) { + return 'ambiguous username'; + } + } + else { + return 'either ID, email or username required'; + } + + return 'ok'; + } else { throw new Exception('Unexpected action: '.$_POST['action']); } @@ -381,4 +415,22 @@ function showGuestUserForm() { echo ' '; echo ''; echo ''; + + echo '
'; + + echo ''; + + echo ''; }