diff --git a/tests/index.php b/tests/index.php index 6aef647..14f7912 100644 --- a/tests/index.php +++ b/tests/index.php @@ -208,6 +208,32 @@ function processRequestData(\Delight\Auth\Auth $auth) { return 'ok'; } + else if ($_POST['action'] === 'admin.createUser') { + try { + if (!isset($_POST['require_unique_username'])) { + $_POST['require_unique_username'] = '0'; + } + + if ($_POST['require_unique_username'] == 0) { + return $auth->admin()->createUser($_POST['email'], $_POST['password'], $_POST['username']); + } + else { + return $auth->admin()->createUserWithUniqueUsername($_POST['email'], $_POST['password'], $_POST['username']); + } + } + catch (\Delight\Auth\InvalidEmailException $e) { + return 'invalid email address'; + } + catch (\Delight\Auth\InvalidPasswordException $e) { + return 'invalid password'; + } + catch (\Delight\Auth\UserAlreadyExistsException $e) { + return 'email address already exists'; + } + catch (\Delight\Auth\DuplicateUsernameException $e) { + return 'username already exists'; + } + } else { throw new Exception('Unexpected action: '.$_POST['action']); } @@ -281,6 +307,8 @@ function showAuthenticatedUserForm() { function showGuestUserForm() { showGeneralForm(); + echo '

Public

'; + echo '
'; echo ''; echo ' '; @@ -339,4 +367,18 @@ function showGuestUserForm() { echo ' '; echo ''; echo '
'; + + echo '

Administration

'; + + echo '
'; + echo ''; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ''; + echo '
'; }