* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @category API
- * @package GNUSocial
+ * @package GNUsocial
* @author Hannes Mannerheim <h@nnesmannerhe.im>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://www.gnu.org/software/social/
*
* @return boolean success flag
*/
- protected function prepare($args)
+ protected function prepare(array $args=array())
{
parent::prepare($args);
}
if (!empty($this->code)) {
- $this->invite = Invitation::staticGet('code', $this->code);
+ $this->invite = Invitation::getKV('code', $this->code);
if (empty($this->invite)) {
// TRANS: Client error displayed when trying to register to an invite-only site without a valid invitation.
$this->clientError(_('Sorry, invalid invitation code.'), 401);
// Input scrubbing
try {
- $nickname = Nickname::normalize($nickname);
+ $nickname = Nickname::normalize($nickname, true);
} catch (NicknameException $e) {
// clientError handles Api exceptions with various formats and stuff
- $this->clientError(_('Not a valid nickname.'), 400);
+ $this->clientError($e->getMessage(), $e->getCode());
}
+
$email = common_canonical_email($email);
if ($email && !Validate::email($email, common_config('email', 'check_domain'))) {
// TRANS: Form validation error displayed when trying to register without a valid e-mail address.
$this->clientError(_('Not a valid email address.'), 400);
- } else if ($this->nicknameExists($nickname)) {
- // TRANS: Form validation error displayed when trying to register with an existing nickname.
- $this->clientError(_('Nickname already in use. Try another one.'), 400);
- } else if (!User::allowed_nickname($nickname)) {
- // TRANS: Form validation error displayed when trying to register with an invalid nickname.
- $this->clientError(_('Not a valid nickname.'), 400);
} else if ($this->emailExists($email)) {
// TRANS: Form validation error displayed when trying to register with an already registered e-mail address.
$this->clientError(_('Email address already exists.'), 400);
}
}
}
-
-
- /**
- * Does the given nickname already exist?
- *
- * Checks a canonical nickname against the database.
- *
- * @param string $nickname nickname to check
- *
- * @return boolean true if the nickname already exists
- */
- function nicknameExists($nickname)
- {
- $user = User::staticGet('nickname', $nickname);
- return is_object($user);
- }
/**
* Does the given email address already exist?
if (!$email || strlen($email) == 0) {
return false;
}
- $user = User::staticGet('email', $email);
+ $user = User::getKV('email', $email);
return is_object($user);
}