const ABORTED = 8;
const CREATE_BLOCKED = 9;
const THROTTLED = 10;
+ const USER_BLOCKED = 11;
var $mName, $mPassword, $mRetype, $mReturnTo, $mCookieCheck, $mPosted;
var $mAction, $mCreateaccount, $mCreateaccountMail, $mMailmypassword;
/**
* Constructor
- * @param WebRequest $request A WebRequest object passed by reference
+ * @param $request WebRequest: a WebRequest object passed by reference
+ * @param $par String: subpage parameter
*/
function LoginForm( &$request, $par = '' ) {
global $wgAuth, $wgHiddenPrefs, $wgEnableEmail, $wgRedirectOnLogin;
function addNewAccountMailPassword() {
global $wgOut;
- if ('' == $this->mEmail) {
+ if ( $this->mEmail == '' ) {
$this->mainLoginForm( wfMsg( 'noemail', htmlspecialchars( $this->mName ) ) );
return;
}
$u = $this->addNewaccountInternal();
- if ($u == NULL) {
+ if ($u == null) {
return;
}
# Create the account and abort if there's a problem doing so
$u = $this->addNewAccountInternal();
- if( $u == NULL )
+ if( $u == null )
return;
# If we showed up language selection links, and one was in use, be
if( $wgUser->isAnon() ) {
$wgUser = $u;
$wgUser->setCookies();
- wfRunHooks( 'AddNewAccount', array( $wgUser ) );
+ wfRunHooks( 'AddNewAccount', array( $wgUser, false ) );
$wgUser->addNewUserLogEntry();
if( $this->hasSessionCookie() ) {
return $this->successfulCreation();
$wgOut->setRobotPolicy( 'noindex,nofollow' );
$wgOut->addHTML( wfMsgWikiHtml( 'accountcreatedtext', $u->getName() ) );
$wgOut->returnToMain( false, $self );
- wfRunHooks( 'AddNewAccount', array( $u ) );
+ wfRunHooks( 'AddNewAccount', array( $u, false ) );
$u->addNewUserLogEntry();
return true;
}
*/
function addNewAccountInternal() {
global $wgUser, $wgOut;
- global $wgEnableSorbs, $wgProxyWhitelist;
global $wgMemc, $wgAccountCreationThrottle;
global $wgAuth, $wgMinimalPasswordLength;
global $wgEmailConfirmToEdit;
// 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( 'local' != $this->mDomain && $this->mDomain != '' ) {
if( !$wgAuth->canCreateAccounts() && ( !$wgAuth->userExists( $this->mName ) || !$wgAuth->authenticate( $this->mName, $this->mPassword ) ) ) {
$this->mainLoginForm( wfMsg( 'wrongpassword' ) );
return false;
}
$ip = wfGetIP();
- if ( $wgEnableSorbs && !in_array( $ip, $wgProxyWhitelist ) &&
- $wgUser->inSorbsBlacklist( $ip ) )
- {
+ if ( $wgUser->isDnsBlacklisted( $ip, true /* check $wgProxyWhitelist */ ) ) {
$this->mainLoginForm( wfMsg( 'sorbs_create_account_reason' ) . ' (' . htmlspecialchars( $ip ) . ')' );
return;
}
# Now create a dummy user ($u) and check if it is valid
$name = trim( $this->mName );
$u = User::newFromName( $name, 'creatable' );
- if ( is_null( $u ) ) {
+ if ( !is_object( $u ) ) {
$this->mainLoginForm( wfMsg( 'noname' ) );
return false;
}
}
# check for minimal password length
- $valid = $u->isValidPassword( $this->mPassword );
+ $valid = $u->getPasswordValidity( $this->mPassword );
if ( $valid !== true ) {
if ( !$this->mCreateaccountMail ) {
$this->mainLoginForm( wfMsgExt( $valid, array( 'parsemag' ), $wgMinimalPasswordLength ) );
$wgAuth->initUser( $u, $autocreate );
if ( $this->mExtUser ) {
- $this->mExtUser->link( $u->getId() );
+ $this->mExtUser->linkToLocal( $u->getId() );
$email = $this->mExtUser->getPref( 'emailaddress' );
if ( $email && !$this->mEmail ) {
$u->setEmail( $email );
* This may create a local account as a side effect if the
* authentication plugin allows transparent local account
* creation.
- *
- * @public
*/
- function authenticateUserData() {
+ public function authenticateUserData() {
global $wgUser, $wgAuth;
- if ( '' == $this->mName ) {
+ if ( $this->mName == '' ) {
return self::NO_NAME;
}
# TODO: Allow some magic here for invalid external names, e.g., let the
# user choose a different wiki name.
$u = User::newFromName( $this->mName );
- if( is_null( $u ) || !User::isUsableName( $u->getName() ) ) {
+ if( !( $u instanceof User ) || !User::isUsableName( $u->getName() ) ) {
return self::ILLEGAL;
}
$isAutoCreated = true;
}
} else {
+ global $wgExternalAuthType, $wgAutocreatePolicy;
+ if ( $wgExternalAuthType && $wgAutocreatePolicy != 'never'
+ && is_object( $this->mExtUser )
+ && $this->mExtUser->authenticate( $this->mPassword ) ) {
+ # The external user and local user have the same name and
+ # password, so we assume they're the same.
+ $this->mExtUser->linkToLocal( $u->getID() );
+ }
+
$u->load();
}
return $abort;
}
+ global $wgBlockDisablesLogin;
if (!$u->checkPassword( $this->mPassword )) {
if( $u->checkTemporaryPassword( $this->mPassword ) ) {
// The e-mailed temporary password should not be used for actu-
// faces etc will probably just fail cleanly here.
$retval = self::RESET_PASS;
} else {
- $retval = '' == $this->mPassword ? self::EMPTY_PASS : self::WRONG_PASS;
+ $retval = ($this->mPassword == '') ? self::EMPTY_PASS : self::WRONG_PASS;
}
+ } elseif ( $wgBlockDisablesLogin && $u->isBlocked() ) {
+ // If we've enabled it, make it so that a blocked user cannot login
+ $retval = self::USER_BLOCKED;
} else {
$wgAuth->updateUser( $u );
$wgUser = $u;
case self::THROTTLED:
$this->mainLoginForm( wfMsg( 'login-throttled' ) );
break;
+ case self::USER_BLOCKED:
+ $this->mainLoginForm( wfMsgExt( 'login-userblocked',
+ array( 'parsemag', 'escape' ), $this->mName ) );
+ break;
default:
throw new MWException( "Unhandled case value" );
}
return;
}
- if ( '' == $this->mName ) {
+ if ( $this->mName == '' ) {
$this->mainLoginForm( wfMsg( 'noname' ) );
return;
}
/**
- * @param object user
- * @param bool throttle
- * @param string message name of email title
- * @param string message name of email text
- * @return mixed true on success, WikiError on failure
+ * @param $u User object
+ * @param $throttle Boolean
+ * @param $emailTitle String: message name of email title
+ * @param $emailText String: message name of email text
+ * @return Mixed: true on success, WikiError on failure
* @private
*/
function mailPasswordInternal( $u, $throttle = true, $emailTitle = 'passwordremindertitle', $emailText = 'passwordremindertext' ) {
global $wgServer, $wgScript, $wgUser, $wgNewPasswordExpiry;
- if ( '' == $u->getEmail() ) {
+ if ( $u->getEmail() == '' ) {
return new WikiError( wfMsg( 'noemail', $u->getName() ) );
}
$ip = wfGetIP();
$np = $u->randomPassword();
$u->setNewpassword( $np, $throttle );
$u->saveSettings();
-
- $m = wfMsgExt( $emailText, array( 'parsemag' ), $ip, $u->getName(), $np,
+ $userLanguage = $u->getOption( 'language' );
+ $m = wfMsgExt( $emailText, array( 'parsemag', 'language' => $userLanguage ), $ip, $u->getName(), $np,
$wgServer . $wgScript, round( $wgNewPasswordExpiry / 86400 ) );
- $result = $u->sendMail( wfMsg( $emailTitle ), $m );
+ $result = $u->sendMail( wfMsgExt( $emailTitle, array( 'parsemag', 'language' => $userLanguage ) ), $m );
return $result;
}
}
}
- if ( '' == $this->mName ) {
+ if ( $this->mName == '' ) {
if ( $wgUser->isLoggedIn() ) {
$this->mName = $wgUser->getName();
} else {
wfRunHooks( 'UserLoginForm', array( &$template ) );
}
- $wgOut->setPageTitle( wfMsg( 'userlogin' ) );
+ //Changes the title depending on permissions for creating account
+ if ( $wgUser->isAllowed( 'createaccount' ) ) {
+ $wgOut->setPageTitle( wfMsg( 'userlogin' ) );
+ } else {
+ $wgOut->setPageTitle( wfMsg( 'userloginnocreate' ) );
+ }
+
$wgOut->setRobotPolicy( 'noindex,nofollow' );
$wgOut->setArticleRelated( false );
$wgOut->disallowUserJs(); // just in case...