* @ingroup SpecialPage
*/
class LoginForm extends SpecialPage {
-
const SUCCESS = 0;
const NO_NAME = 1;
const ILLEGAL = 2;
const NEED_TOKEN = 12;
const WRONG_TOKEN = 13;
- var $mUsername, $mPassword, $mRetype, $mReturnTo, $mCookieCheck, $mPosted;
- var $mAction, $mCreateaccount, $mCreateaccountMail;
- var $mLoginattempt, $mRemember, $mEmail, $mDomain, $mLanguage;
- var $mSkipCookieCheck, $mReturnToQuery, $mToken, $mStickHTTPS;
- var $mType, $mReason, $mRealName;
- var $mAbortLoginErrorMsg = null;
+ public $mAbortLoginErrorMsg = null;
+
+ protected $mUsername;
+ protected $mPassword;
+ protected $mRetype;
+ protected $mReturnTo;
+ protected $mCookieCheck;
+ protected $mPosted;
+ protected $mAction;
+ protected $mCreateaccount;
+ protected $mCreateaccountMail;
+ protected $mLoginattempt;
+ protected $mRemember;
+ protected $mEmail;
+ protected $mDomain;
+ protected $mLanguage;
+ protected $mSkipCookieCheck;
+ protected $mReturnToQuery;
+ protected $mToken;
+ protected $mStickHTTPS;
+ protected $mType;
+ protected $mReason;
+ protected $mRealName;
+
private $mTempPasswordUsed;
private $mLoaded = false;
private $mSecureLoginUrl;
- /**
- * @ var WebRequest
- */
+ /** @var WebRequest */
private $mOverrideRequest = null;
- /**
- * Effective request; set at the beginning of load
- *
- * @var WebRequest $mRequest
- */
+ /** @var WebRequest Effective request; set at the beginning of load */
private $mRequest = null;
/**
$this->mAction = $request->getVal( 'action' );
$this->mRemember = $request->getCheck( 'wpRemember' );
$this->mFromHTTP = $request->getBool( 'fromhttp', false );
- $this->mStickHTTPS = ( !$this->mFromHTTP && $request->getProtocol() === 'https' ) || $request->getBool( 'wpForceHttps', false );
+ $this->mStickHTTPS = ( !$this->mFromHTTP && $request->getProtocol() === 'https' )
+ || $request->getBool( 'wpForceHttps', false );
$this->mLanguage = $request->getText( 'uselang' );
$this->mSkipCookieCheck = $request->getCheck( 'wpSkipCookieCheck' );
- $this->mToken = ( $this->mType == 'signup' ) ? $request->getVal( 'wpCreateaccountToken' ) : $request->getVal( 'wpLoginToken' );
+ $this->mToken = $this->mType == 'signup'
+ ? $request->getVal( 'wpCreateaccountToken' )
+ : $request->getVal( 'wpLoginToken' );
$this->mReturnTo = $request->getVal( 'returnto', '' );
$this->mReturnToQuery = $request->getVal( 'returntoquery', '' );
}
/*
- * @param $subPage string|null
+ * @param string|null $subPage
*/
public function execute( $subPage ) {
if ( session_id() == '' ) {
}
# Include checks that will include GlobalBlocking (Bug 38333)
- $permErrors = $this->getPageTitle()->getUserPermissionsErrors( 'createaccount', $currentUser, true );
+ $permErrors = $this->getPageTitle()->getUserPermissionsErrors(
+ 'createaccount',
+ $currentUser,
+ true
+ );
+
if ( count( $permErrors ) ) {
throw new PermissionsError( 'createaccount', $permErrors );
}
return Status::newFatal( 'sorbs_create_account_reason' );
}
- // Normalize the name so that silly things don't cause "invalid username" errors.
- // User::newFromName does some rather strict checking, rejecting e.g. leading/trailing/multiple spaces.
+ // Normalize the name so that silly things don't cause "invalid username"
+ // errors. User::newFromName does some rather strict checking, rejecting
+ // e.g. leading/trailing/multiple spaces.
$title = Title::makeTitleSafe( NS_USER, $this->mUsername );
if ( !is_object( $title ) ) {
return Status::newFatal( 'noname' );
// Hook point to check for exempt from account creation throttle
if ( !wfRunHooks( 'ExemptFromAccountCreationThrottle', array( $ip ) ) ) {
- wfDebug( "LoginForm::exemptFromAccountCreationThrottle: a hook allowed account creation w/o throttle\n" );
+ wfDebug( "LoginForm::exemptFromAccountCreationThrottle: a hook " .
+ "allowed account creation w/o throttle\n" );
} else {
if ( ( $wgAccountCreationThrottle && $currentUser->isPingLimitable() ) ) {
$key = wfMemcKey( 'acctcreate', 'ip', $ip );
* Actually add a user to the database.
* Give it a User object that has been initialised with a name.
*
- * @param $u User object.
- * @param $autocreate boolean -- true if this is an autocreation via auth plugin
- * @return Status object, with the User object in the value member on success
+ * @param User $u
+ * @param bool $autocreate True if this is an autocreation via auth plugin
+ * @return Status Status object, with the User object in the value member on success
* @private
*/
function initUser( $u, $autocreate ) {
$wgAuth->initUser( $u, $autocreate );
- $u->setOption( 'rememberpassword', $this->mRemember ? 1 : 0 );
$u->saveSettings();
// Update user count
* Increment the login attempt throttle hit count for the (username,current IP)
* tuple unless the throttle was already reached.
* @param string $username The user name
- * @return Bool|Integer The integer hit count or True if it is already at the limit
+ * @return bool|int The integer hit count or True if it is already at the limit
*/
public static function incLoginThrottle( $username ) {
global $wgPasswordAttemptThrottle, $wgMemc, $wgRequest;
* Attempt to automatically create a user on login. Only succeeds if there
* is an external authentication method which allows it.
*
- * @param $user User
+ * @param User $user
*
- * @return integer Status code
+ * @return int Status code
*/
function attemptAutoCreate( $user ) {
global $wgAuth;
function processLogin() {
global $wgMemc, $wgLang, $wgSecureLogin, $wgPasswordAttemptThrottle,
- $wgInvalidPasswordReset;
+ $wgInvalidPasswordReset;
switch ( $this->authenticateUserData() ) {
case self::SUCCESS:
# We've verified now, update the real record
$user = $this->getUser();
- if ( (bool)$this->mRemember != $user->getBoolOption( 'rememberpassword' ) ) {
- $user->setOption( 'rememberpassword', $this->mRemember ? 1 : 0 );
- $user->saveSettings();
- } else {
- $user->invalidateCache();
- }
+ $user->invalidateCache();
if ( $user->requiresHTTPS() ) {
$this->mStickHTTPS = true;
}
if ( $wgSecureLogin && !$this->mStickHTTPS ) {
- $user->setCookies( null, false );
+ $user->setCookies( $this->mRequest, false, $this->mRemember );
} else {
- $user->setCookies();
+ $user->setCookies( $this->mRequest, null, $this->mRemember );
}
self::clearLoginToken();
}
/**
- * @param $u User object
- * @param $throttle Boolean
- * @param string $emailTitle message name of email title
- * @param string $emailText message name of email text
- * @return Status object
+ * @param User $u
+ * @param bool $throttle
+ * @param string $emailTitle Message name of email title
+ * @param string $emailText Message name of email text
+ * @return Status
*/
- function mailPasswordInternal( $u, $throttle = true, $emailTitle = 'passwordremindertitle', $emailText = 'passwordremindertext' ) {
+ function mailPasswordInternal( $u, $throttle = true, $emailTitle = 'passwordremindertitle',
+ $emailText = 'passwordremindertext'
+ ) {
global $wgNewPasswordExpiry;
if ( $u->getEmail() == '' ) {
/**
* Display an "successful action" page.
*
- * @param string|Message $title page's title
- * @param $msgname string
- * @param $injected_html string
+ * @param string|Message $title Page's title
+ * @param string $msgname
+ * @param string $injected_html
*/
private function displaySuccessfulAction( $title, $msgname, $injected_html ) {
$out = $this->getOutput();
* there is a block on them or their IP which prevents account creation. Note that
* User::isBlockedFromCreateAccount(), which gets this block, ignores the 'hardblock'
* setting on blocks (bug 13611).
- * @param $block Block the block causing this error
+ * @param Block $block The block causing this error
* @throws ErrorPageError
*/
function userBlockedMessage( Block $block ) {
* Extensions can use this to reuse the "return to" logic after
* inject steps (such as redirection) into the login process.
*
- * @param $type string, one of the following:
+ * @param string $type One of the following:
* - error: display a return to link ignoring $wgRedirectOnLogin
* - success: display a return to link using $wgRedirectOnLogin if needed
* - successredirect: send an HTTP redirect using $wgRedirectOnLogin if needed
/**
* Add a "return to" link or redirect to it.
*
- * @param $type string, one of the following:
+ * @param string $type One of the following:
* - error: display a return to link ignoring $wgRedirectOnLogin
* - success: display a return to link using $wgRedirectOnLogin if needed
* - successredirect: send an HTTP redirect using $wgRedirectOnLogin if needed
$template->set( 'resetlink', $resetLink );
$template->set( 'canremember', ( $wgCookieExpiration > 0 ) );
$template->set( 'usereason', $user->isLoggedIn() );
- $template->set( 'remember', $user->getOption( 'rememberpassword' ) || $this->mRemember );
+ $template->set( 'remember', $this->mRemember );
$template->set( 'cansecurelogin', ( $wgSecureLogin === true ) );
$template->set( 'stickhttps', (int)$this->mStickHTTPS );
$template->set( 'loggedin', $user->isLoggedIn() );
* Whether the login/create account form should display a link to the
* other form (in addition to whatever the skin provides).
*
- * @param $user User
+ * @param User $user
* @return bool
*/
private function showCreateOrLoginLink( &$user ) {
/**
* Get the login token from the current session
- * @return Mixed
+ * @return mixed
*/
public static function getLoginToken() {
global $wgRequest;
/**
* Get the createaccount token from the current session
- * @return Mixed
+ * @return mixed
*/
public static function getCreateaccountToken() {
global $wgRequest;