$result = $this->mailPasswordInternal( $u, false, 'createaccount-title', 'createaccount-text' );
wfRunHooks( 'AddNewAccount', array( $u, true ) );
+ $u->addNewUserLogEntry();
$wgOut->setPageTitle( wfMsg( 'accmailtitle' ) );
$wgOut->setRobotPolicy( 'noindex,nofollow' );
# Save settings (including confirmation token)
$u->saveSettings();
- # If not logged in, assume the new account as the current one and set session cookies
- # then show a "welcome" message or a "need cookies" message as needed
+ # If not logged in, assume the new account as the current one and set
+ # session cookies then show a "welcome" message or a "need cookies"
+ # message as needed
if( $wgUser->isAnon() ) {
$wgUser = $u;
$wgUser->setCookies();
wfRunHooks( 'AddNewAccount', array( $wgUser ) );
+ $wgUser->addNewUserLogEntry();
if( $this->hasSessionCookie() ) {
return $this->successfulCreation();
} else {
$wgOut->addHtml( wfMsgWikiHtml( 'accountcreatedtext', $u->getName() ) );
$wgOut->returnToMain( false, $self );
wfRunHooks( 'AddNewAccount', array( $u ) );
+ $u->addNewUserLogEntry();
return true;
}
}
return false;
}
- // If we are not allowing users to login locally, we should
- // be checking to see if the user is actually able to
- // authenticate to the authentication server before they
- // create an account (otherwise, they can create a local account
- // and login as any domain user). We only need to check this for
- // domains that aren't local.
+ // If we are not allowing users to login locally, we should be checking
+ // to see if the user is actually able to authenticate to the authenti-
+ // cation server before they create an account (otherwise, they can
+ // create a local account and login as any domain user). We only need
+ // to check this for domains that aren't local.
if( 'local' != $this->mDomain && '' != $this->mDomain ) {
if( !$wgAuth->canCreateAccounts() && ( !$wgAuth->userExists( $this->mName ) || !$wgAuth->authenticate( $this->mName, $this->mPassword ) ) ) {
$this->mainLoginForm( wfMsg( 'wrongpassword' ) );
}
}
- # if you need a confirmed email address to edit, then obviously you need an email address.
+ # if you need a confirmed email address to edit, then obviously you
+ # need an email address.
if ( $wgEmailConfirmToEdit && empty( $this->mEmail ) ) {
$this->mainLoginForm( wfMsg( 'noemailtitle' ) );
return false;
return false;
}
- # Set some additional data so the AbortNewAccount hook can be
- # used for more than just username validation
+ # Set some additional data so the AbortNewAccount hook can be used for
+ # more than just username validation
$u->setEmail( $this->mEmail );
$u->setRealName( $this->mRealName );
}
global $wgPasswordAttemptThrottle;
+
+ $throttleCount=0;
if ( is_array($wgPasswordAttemptThrottle) ) {
- $key = wfMemcKey( 'password-throttle', wfGetIP(), md5( $this->mName ) );
+ $throttleKey = wfMemcKey( 'password-throttle', wfGetIP(), md5( $this->mName ) );
$count = $wgPasswordAttemptThrottle['count'];
$period = $wgPasswordAttemptThrottle['seconds'];
global $wgMemc;
- $cur = $wgMemc->get($key);
- if ( !$cur ) {
- $wgMemc->add( $key, 1, $period ); // start counter
- } else if ( $cur < $count ) {
- $wgMemc->incr($key);
- } else if ( $cur >= $count ) {
+ $throttleCount = $wgMemc->get($throttleKey);
+ if ( !$throttleCount ) {
+ $wgMemc->add( $throttleKey, 1, $period ); // start counter
+ } else if ( $throttleCount < $count ) {
+ $wgMemc->incr($throttleKey);
+ } else if ( $throttleCount >= $count ) {
return self::THROTTLED;
}
}
- // 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
- // the UserLoadFromSession hook, which potentially creates the user in the
- // database. Until we load $wgUser, checking for user existence using
- // User::newFromName($name)->getId() below will effectively be using stale data.
+ // 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 the UserLoadFromSession hook, which potentially
+ // creates the user in the database. Until we load $wgUser, checking
+ // for user existence using User::newFromName($name)->getId() below
+ // will effectively be using stale data.
if ( $wgUser->getName() === $this->mName ) {
wfDebug( __METHOD__.": already logged in as {$this->mName}\n" );
return self::SUCCESS;
if (!$u->checkPassword( $this->mPassword )) {
if( $u->checkTemporaryPassword( $this->mPassword ) ) {
- // The e-mailed temporary password should not be used
- // for actual logins; that's a very sloppy habit,
- // and insecure if an attacker has a few seconds to
- // click "search" on someone's open mail reader.
- //
- // Allow it to be used only to reset the password
- // a single time to a new value, which won't be in
- // the user's e-mail archives.
+ // The e-mailed temporary password should not be used for actu-
+ // al logins; that's a very sloppy habit, and insecure if an
+ // attacker has a few seconds to click "search" on someone's o-
+ // pen mail reader.
//
- // For backwards compatibility, we'll still recognize
- // it at the login form to minimize surprises for
- // people who have been logging in with a temporary
- // password for some time.
+ // Allow it to be used only to reset the password a single time
+ // to a new value, which won't be in the user's e-mail ar-
+ // chives.
//
- // As a side-effect, we can authenticate the user's
- // e-mail address if it's not already done, since
- // the temporary password was sent via e-mail.
+ // For backwards compatibility, we'll still recognize it at the
+ // login form to minimize surprises for people who have been
+ // logging in with a temporary password for some time.
//
+ // As a side-effect, we can authenticate the user's e-mail ad-
+ // dress if it's not already done, since the temporary password
+ // was sent via e-mail.
if( !$u->isEmailConfirmed() ) {
$u->confirmEmail();
$u->saveSettings();
}
- // At this point we just return an appropriate code
- // indicating that the UI should show a password
- // reset form; bot interfaces etc will probably just
- // fail cleanly here.
- //
+ // At this point we just return an appropriate code/ indicating
+ // that the UI should show a password reset form; bot inter-
+ // faces etc will probably just fail cleanly here.
$retval = self::RESET_PASS;
} else {
$retval = '' == $this->mPassword ? self::EMPTY_PASS : self::WRONG_PASS;
$wgAuth->updateUser( $u );
$wgUser = $u;
+ // Please reset throttle for successful logins, thanks!
+ if($throttleCount) {
+ $wgMemc->delete($throttleKey);
+ }
+
if ( $isAutoCreated ) {
// Must be run after $wgUser is set, for correct new user log
wfRunHooks( 'AuthPluginAutoCreate', array( $wgUser ) );
}
/**
- * Attempt to automatically create a user on login.
- * Only succeeds if there is an external authentication method which allows it.
+ * Attempt to automatically create a user on login. Only succeeds if there
+ * is an external authentication method which allows it.
* @return integer Status code
*/
function attemptAutoCreate( $user ) {
global $wgAuth, $wgUser;
/**
- * If the external authentication plugin allows it,
- * automatically create a new account for users that
- * are externally defined but have not yet logged in.
+ * If the external authentication plugin allows it, automatically cre-
+ * ate a new account for users that are externally defined but have not
+ * yet logged in.
*/
if ( !$wgAuth->autoCreate() ) {
return self::NOT_EXISTS;
$wgMemc->delete( $key );
if( $this->hasSessionCookie() || $this->mSkipCookieCheck ) {
- /* Replace the language object to provide user interface in correct
- * language immediately on this first page load.
+ /* Replace the language object to provide user interface in
+ * correct language immediately on this first page load.
*/
global $wgLang, $wgRequest;
$code = $wgRequest->getVal( 'uselang', $wgUser->getOption( 'language' ) );
break;
case self::NOT_EXISTS:
if( $wgUser->isAllowed( 'createaccount' ) ){
- $this->mainLoginForm( wfMsg( 'nosuchuser', htmlspecialchars( $this->mName ) ) );
+ $this->mainLoginForm( wfMsgWikiHtml( 'nosuchuser', htmlspecialchars( $this->mName ) ) );
} else {
$this->mainLoginForm( wfMsg( 'nosuchusershort', htmlspecialchars( $this->mName ) ) );
}
return;
}
if ( 0 == $u->getID() ) {
- $this->mainLoginForm( wfMsg( 'nosuchuser', $u->getName() ) );
+ $this->mainLoginForm( wfMsgWikiHtml( 'nosuchuser', htmlspecialchars( $u->getName() ) ) );
return;
}
# Check against password throttle
if ( $u->isPasswordReminderThrottled() ) {
global $wgPasswordReminderResendTime;
- # Round the time in hours to 3 d.p., in case someone is specifying minutes or seconds.
+ # Round the time in hours to 3 d.p., in case someone is specifying
+ # minutes or seconds.
$this->mainLoginForm( wfMsgExt( 'throttled-mailpassword', array( 'parsemag' ),
round( $wgPasswordReminderResendTime, 3 ) ) );
return;
* Display a "login successful" page.
*/
private function displaySuccessfulLogin( $msgname, $injected_html ) {
- global $wgOut;
+ global $wgOut, $wgUser;
$wgOut->setPageTitle( wfMsg( 'loginsuccesstitle' ) );
$wgOut->setRobotPolicy( 'noindex,nofollow' );
$wgOut->setArticleRelated( false );
$wgOut->addWikitext( $wgOut->formatPermissionsErrorMessage( $errors, 'createaccount' ) );
- // Stuff that might want to be added at the end. For example, instructions if blocked.
+ // Stuff that might want to be added at the end. For example, instruc-
+ // tions if blocked.
$wgOut->addWikiMsg( 'cantcreateaccount-nonblock-text' );
$wgOut->returnToMain( false );
/**
* Check if a session cookie is present.
*
- * This will not pick up a cookie set during _this_ request, but is
- * meant to ensure that the client is returning the cookie which was
- * set on a previous pass through the system.
+ * This will not pick up a cookie set during _this_ request, but is meant
+ * to ensure that the client is returning the cookie which was set on a
+ * previous pass through the system.
*
* @private
*/
* @private
*/
function throttleHit( $limit ) {
- global $wgOut;
-
- $wgOut->addWikiMsg( 'acct_creation_throttle_hit', $limit );
+ $this->mainLoginForm( wfMsgExt( 'acct_creation_throttle_hit', array( 'parseinline' ), $limit ) );
}
/**