Fixes for RegisterThrottle plugin: alt registration methods (OpenID, FBConnect, Twitter) weren't triggering the throttle check or recording of IPs.
Added StartRegistrationTry/EndRegistrationTry calls into those three, and moved the actual recording hook to EndUserRegister which is guaranteed to be called from User::register (so we don't need to worry about other auth methods forgetting to call the other UI-code hooks).
This commit is contained in:
parent
fb9ecddbf1
commit
d0d39b51b8
@ -232,6 +232,10 @@ class FBConnectauthAction extends Action
|
|||||||
|
|
||||||
function createNewUser()
|
function createNewUser()
|
||||||
{
|
{
|
||||||
|
if (!Event::handle('StartRegistrationTry', array($this))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (common_config('site', 'closed')) {
|
if (common_config('site', 'closed')) {
|
||||||
// TRANS: Client error trying to register with registrations not allowed.
|
// TRANS: Client error trying to register with registrations not allowed.
|
||||||
$this->clientError(_m('Registration not allowed.'));
|
$this->clientError(_m('Registration not allowed.'));
|
||||||
@ -300,6 +304,8 @@ class FBConnectauthAction extends Action
|
|||||||
common_debug('Facebook Connect Plugin - ' .
|
common_debug('Facebook Connect Plugin - ' .
|
||||||
"Registered new user $user->id from Facebook user $this->fbuid");
|
"Registered new user $user->id from Facebook user $this->fbuid");
|
||||||
|
|
||||||
|
Event::handle('EndRegistrationTry', array($this));
|
||||||
|
|
||||||
common_redirect(common_local_url('showstream', array('nickname' => $user->nickname)),
|
common_redirect(common_local_url('showstream', array('nickname' => $user->nickname)),
|
||||||
303);
|
303);
|
||||||
}
|
}
|
||||||
|
@ -247,6 +247,10 @@ class FinishopenidloginAction extends Action
|
|||||||
{
|
{
|
||||||
# FIXME: save invite code before redirect, and check here
|
# FIXME: save invite code before redirect, and check here
|
||||||
|
|
||||||
|
if (!Event::handle('StartRegistrationTry', array($this))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (common_config('site', 'closed')) {
|
if (common_config('site', 'closed')) {
|
||||||
// TRANS: OpenID plugin message. No new user registration is allowed on the site.
|
// TRANS: OpenID plugin message. No new user registration is allowed on the site.
|
||||||
$this->clientError(_m('Registration not allowed.'));
|
$this->clientError(_m('Registration not allowed.'));
|
||||||
@ -362,6 +366,9 @@ class FinishopenidloginAction extends Action
|
|||||||
common_rememberme($user);
|
common_rememberme($user);
|
||||||
}
|
}
|
||||||
unset($_SESSION['openid_rememberme']);
|
unset($_SESSION['openid_rememberme']);
|
||||||
|
|
||||||
|
Event::handle('EndRegistrationTry', array($this));
|
||||||
|
|
||||||
common_redirect(common_local_url('showstream', array('nickname' => $user->nickname)),
|
common_redirect(common_local_url('showstream', array('nickname' => $user->nickname)),
|
||||||
303);
|
303);
|
||||||
}
|
}
|
||||||
|
@ -167,28 +167,24 @@ class RegisterThrottlePlugin extends Plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called after someone registers.
|
* Called after someone registers, by any means.
|
||||||
*
|
*
|
||||||
* We record the successful registration and IP address.
|
* We record the successful registration and IP address.
|
||||||
*
|
*
|
||||||
* @param Action $action Action that is being executed
|
* @param Profile $profile new user's profile
|
||||||
|
* @param User $user new user
|
||||||
*
|
*
|
||||||
* @return boolean hook value
|
* @return boolean hook value
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function onEndRegistrationTry($action)
|
function onEndUserRegister($profile, $user)
|
||||||
{
|
{
|
||||||
$ipaddress = $this->_getIpAddress();
|
$ipaddress = $this->_getIpAddress();
|
||||||
|
|
||||||
if (empty($ipaddress)) {
|
if (empty($ipaddress)) {
|
||||||
throw new ServerException(_m('Cannot find IP address.'));
|
// User registration can happen from command-line scripts etc.
|
||||||
}
|
return true;
|
||||||
|
|
||||||
$user = common_current_user();
|
|
||||||
|
|
||||||
if (empty($user)) {
|
|
||||||
throw new ServerException(_m('Cannot find user after successful registration.'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$reg = new Registration_ip();
|
$reg = new Registration_ip();
|
||||||
|
@ -419,6 +419,10 @@ class TwitterauthorizationAction extends Action
|
|||||||
|
|
||||||
function createNewUser()
|
function createNewUser()
|
||||||
{
|
{
|
||||||
|
if (!Event::handle('StartRegistrationTry', array($this))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (common_config('site', 'closed')) {
|
if (common_config('site', 'closed')) {
|
||||||
$this->clientError(_m('Registration not allowed.'));
|
$this->clientError(_m('Registration not allowed.'));
|
||||||
return;
|
return;
|
||||||
@ -492,6 +496,8 @@ class TwitterauthorizationAction extends Action
|
|||||||
common_debug('TwitterBridge Plugin - ' .
|
common_debug('TwitterBridge Plugin - ' .
|
||||||
"Registered new user $user->id from Twitter user $this->twuid");
|
"Registered new user $user->id from Twitter user $this->twuid");
|
||||||
|
|
||||||
|
Event::handle('EndRegistrationTry', array($this));
|
||||||
|
|
||||||
common_redirect(common_local_url('showstream', array('nickname' => $user->nickname)),
|
common_redirect(common_local_url('showstream', array('nickname' => $user->nickname)),
|
||||||
303);
|
303);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user