Skip to content

Commit

Permalink
Ensure that a new admin account does not already exist
Browse files Browse the repository at this point in the history
refs #7163
  • Loading branch information
Johannes Meyer committed Oct 8, 2014
1 parent 393191c commit 647447b
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions application/forms/Setup/AdminAccountPage.php
Expand Up @@ -187,6 +187,27 @@ public function createElements(array $formData)
);
}

/**
* Validate the given request data and ensure that any new user does not already exist
*
* @param array $data The request data to validate
*
* @return bool
*/
public function isValid($data)
{
if (false === parent::isValid($data)) {
return false;
}

if ($data['user_type'] === 'new_user' && array_search($data['new_user'], $this->fetchUsers()) !== false) {
$this->getElement('new_user')->addError(t('Username already exists.'));
return false;
}

return true;
}

/**
* Return the name of the externally authenticated user
*
Expand Down

0 comments on commit 647447b

Please sign in to comment.