forked from GNUsocial/gnu-social
Don't use bogus event in emailregistration
I was trying to be smart by calling the same registration event as 'register' when doing EmailRegistration. However, that event is so low-bandwidth that plugins go fingerpoken in all the attributes and call methods on the passed-in action and things like that. So, now we just fall back to using the low-level stuff, catch any exceptions, and feel happy. Some stuff might not work, but it's generally anti-spam stuff more suited to public sites.
This commit is contained in:
parent
1619578818
commit
997b0933ea
@ -141,9 +141,9 @@ class BlacklistPlugin extends Plugin
|
|||||||
*
|
*
|
||||||
* @return boolean hook value
|
* @return boolean hook value
|
||||||
*/
|
*/
|
||||||
function onStartRegistrationTry($action)
|
function onStartRegisterUser(&$user, &$profile)
|
||||||
{
|
{
|
||||||
$homepage = strtolower($action->trimmed('homepage'));
|
$homepage = strtolower($profile->homepage);
|
||||||
|
|
||||||
if (!empty($homepage)) {
|
if (!empty($homepage)) {
|
||||||
if (!$this->_checkUrl($homepage)) {
|
if (!$this->_checkUrl($homepage)) {
|
||||||
@ -154,7 +154,7 @@ class BlacklistPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$nickname = strtolower($action->trimmed('nickname'));
|
$nickname = strtolower($profile->nickname);
|
||||||
|
|
||||||
if (!empty($nickname)) {
|
if (!empty($nickname)) {
|
||||||
if (!$this->_checkNickname($nickname)) {
|
if (!$this->_checkNickname($nickname)) {
|
||||||
|
@ -264,7 +264,6 @@ class EmailregisterAction extends Action
|
|||||||
|
|
||||||
function setPassword()
|
function setPassword()
|
||||||
{
|
{
|
||||||
if (Event::handle('StartRegistrationTry', array($this))) {
|
|
||||||
if (!empty($this->invitation)) {
|
if (!empty($this->invitation)) {
|
||||||
$email = $this->invitation->address;
|
$email = $this->invitation->address;
|
||||||
} else if (!empty($this->confirmation)) {
|
} else if (!empty($this->confirmation)) {
|
||||||
@ -293,10 +292,18 @@ class EmailregisterAction extends Action
|
|||||||
|
|
||||||
$nickname = $this->nicknameFromEmail($email);
|
$nickname = $this->nicknameFromEmail($email);
|
||||||
|
|
||||||
|
try {
|
||||||
$this->user = User::register(array('nickname' => $nickname,
|
$this->user = User::register(array('nickname' => $nickname,
|
||||||
'email' => $email,
|
'email' => $email,
|
||||||
'password' => $this->password1,
|
'password' => $this->password1,
|
||||||
'email_confirmed' => true));
|
'email_confirmed' => true));
|
||||||
|
} catch (ClientException $e) {
|
||||||
|
$this->error = $e->getMessage();
|
||||||
|
$nickname = $this->nicknameFromEmail($email);
|
||||||
|
$this->form = new ConfirmRegistrationForm($this, $nickname, $this->email, $this->code);
|
||||||
|
$this->showPage();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($this->user)) {
|
if (empty($this->user)) {
|
||||||
throw new Exception("Failed to register user.");
|
throw new Exception("Failed to register user.");
|
||||||
@ -323,9 +330,6 @@ class EmailregisterAction extends Action
|
|||||||
throw new Exception('No confirmation thing.');
|
throw new Exception('No confirmation thing.');
|
||||||
}
|
}
|
||||||
|
|
||||||
Event::handle('EndRegistrationTry', array($this));
|
|
||||||
}
|
|
||||||
|
|
||||||
common_redirect(common_local_url('doc', array('title' => 'welcome')),
|
common_redirect(common_local_url('doc', array('title' => 'welcome')),
|
||||||
303);
|
303);
|
||||||
}
|
}
|
||||||
|
@ -147,6 +147,26 @@ class RequireValidatedEmailPlugin extends Plugin
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event handler for registration attempts; rejects the registration
|
||||||
|
* if email field is missing.
|
||||||
|
*
|
||||||
|
* @param Action $action Action being executed
|
||||||
|
*
|
||||||
|
* @return bool hook result code
|
||||||
|
*/
|
||||||
|
|
||||||
|
function onStartRegisterUser(&$user, &$profile)
|
||||||
|
{
|
||||||
|
$email = $user->email;
|
||||||
|
|
||||||
|
if (empty($email)) {
|
||||||
|
throw new ClientException(_m('You must provide an email address to register.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a user has a validated email address or has been
|
* Check if a user has a validated email address or has been
|
||||||
* otherwise grandfathered in.
|
* otherwise grandfathered in.
|
||||||
|
Loading…
Reference in New Issue
Block a user