const RESET_PASS = 7;
const ABORTED = 8;
const CREATE_BLOCKED = 9;
+ const THROTTLED = 10;
var $mName, $mPassword, $mRetype, $mReturnTo, $mCookieCheck, $mPosted;
var $mAction, $mCreateaccount, $mCreateaccountMail, $mMailmypassword;
wfRunHooks( 'AddNewAccount', array( $u, true ) );
$wgOut->setPageTitle( wfMsg( 'accmailtitle' ) );
- $wgOut->setRobotpolicy( 'noindex,nofollow' );
+ $wgOut->setRobotPolicy( 'noindex,nofollow' );
$wgOut->setArticleRelated( false );
if( WikiError::isError( $result ) ) {
$wgUser->setCookies();
wfRunHooks( 'AddNewAccount', array( $wgUser ) );
if( $this->hasSessionCookie() ) {
- return $this->successfulLogin( wfMsg( 'welcomecreation', $wgUser->getName() ), false );
+ return $this->successfulLogin( 'welcomecreation', $wgUser->getName(), false );
} else {
return $this->cookieRedirectCheck( 'new' );
}
if ( '' == $this->mName ) {
return self::NO_NAME;
}
+
+ global $wgPasswordAttemptThrottle;
+ if (is_array($wgPasswordAttemptThrottle) && count($wgPasswordAttemptThrottle) >=2) {
+ list($count,$period) = $wgPasswordAttemptThrottle;
+ $key = wfMemcKey( 'password-throttle', wfGetIP(), $this->mName );
+
+ global $wgMemc;
+ $cur = $wgMemc->get($key);
+ if ($cur>0 && $cur<$count) {
+ $wgMemc->incr($key);
+ // Okay
+ } elseif ($cur>0) {
+ return self::THROTTLED;
+ } elseif (!$cur) {
+ $wgMemc->add( $key, 1, $period );
+ }
+ }
// Load $wgUser now, and check to see if we're logging in as the same name.
// This is necessary because loading $wgUser (say by calling getName()) calls
global $wgLang, $wgRequest;
$code = $wgRequest->getVal( 'uselang', $wgUser->getOption( 'language' ) );
$wgLang = Language::factory( $code );
- return $this->successfulLogin( wfMsg( 'loginsuccess', $wgUser->getName() ) );
+ return $this->successfulLogin( 'loginsuccess', $wgUser->getName() );
} else {
return $this->cookieRedirectCheck( 'login' );
}
case self::CREATE_BLOCKED:
$this->userBlockedMessage();
break;
+ case self::THROTTLED:
+ $this->mainLoginForm( wfMsg( 'login-throttled' ) );
+ break;
default:
throw new MWException( "Unhandled case value" );
}
/**
- * @param string $msg Message that will be shown on success
+ * @param string $msg Message key that will be shown on success
+ * @param $params String: parameters for the above message
* @param bool $auto Toggle auto-redirect to main page; default true
* @private
*/
- function successfulLogin( $msg, $auto = true ) {
+ function successfulLogin( $msg, $params, $auto = true ) {
global $wgUser;
global $wgOut;
wfRunHooks('UserLoginComplete', array(&$wgUser, &$injected_html));
$wgOut->setPageTitle( wfMsg( 'loginsuccesstitle' ) );
- $wgOut->setRobotpolicy( 'noindex,nofollow' );
+ $wgOut->setRobotPolicy( 'noindex,nofollow' );
$wgOut->setArticleRelated( false );
- $wgOut->addWikiText( $msg );
+ $wgOut->addWikiMsgArray( $msg, $params );
$wgOut->addHtml( $injected_html );
if ( !empty( $this->mReturnTo ) ) {
$wgOut->returnToMain( $auto, $this->mReturnTo );
global $wgOut;
$wgOut->setPageTitle( wfMsg( 'permissionserrors' ) );
- $wgOut->setRobotpolicy( 'noindex,nofollow' );
+ $wgOut->setRobotPolicy( 'noindex,nofollow' );
$wgOut->setArticleRelated( false );
$wgOut->addWikitext( $wgOut->formatPermissionsErrorMessage( $errors, 'createaccount' ) );
# out.
$wgOut->setPageTitle( wfMsg( 'cantcreateaccounttitle' ) );
- $wgOut->setRobotpolicy( 'noindex,nofollow' );
+ $wgOut->setRobotPolicy( 'noindex,nofollow' );
$wgOut->setArticleRelated( false );
$ip = wfGetIP();
}
$wgOut->setPageTitle( wfMsg( 'userlogin' ) );
- $wgOut->setRobotpolicy( 'noindex,nofollow' );
+ $wgOut->setRobotPolicy( 'noindex,nofollow' );
$wgOut->setArticleRelated( false );
$wgOut->disallowUserJs(); // just in case...
$wgOut->addTemplate( $template );
return $this->mainLoginForm( wfMsg( 'error' ) );
}
} else {
- return $this->successfulLogin( wfMsgExt( 'loginsuccess', array( 'parseinline' ), $wgUser->getName() ) );
+ return $this->successfulLogin( 'loginsuccess', $wgUser->getName() );
}
}