Ensure that a new admin account does not already exist

refs #7163
This commit is contained in:
Johannes Meyer 2014-10-08 10:38:04 +02:00
parent 393191ced1
commit 647447b4d2
1 changed files with 21 additions and 0 deletions

View File

@ -187,6 +187,27 @@ class AdminAccountPage extends Form
);
}
/**
* 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
*