4 * @addtogroup SpecialPage
10 function wfSpecialUserlogin() {
12 if( session_id() == '' ) {
16 $form = new LoginForm( $wgRequest );
21 * implements Special:Login
22 * @addtogroup SpecialPage
29 const WRONG_PLUGIN_PASS
= 3;
36 var $mName, $mPassword, $mRetype, $mReturnTo, $mCookieCheck, $mPosted;
37 var $mAction, $mCreateaccount, $mCreateaccountMail, $mMailmypassword;
38 var $mLoginattempt, $mRemember, $mEmail, $mDomain, $mLanguage;
42 * @param WebRequest $request A WebRequest object passed by reference
44 function LoginForm( &$request ) {
45 global $wgLang, $wgAllowRealName, $wgEnableEmail;
48 $this->mType
= $request->getText( 'type' );
49 $this->mName
= $request->getText( 'wpName' );
50 $this->mPassword
= $request->getText( 'wpPassword' );
51 $this->mRetype
= $request->getText( 'wpRetype' );
52 $this->mDomain
= $request->getText( 'wpDomain' );
53 $this->mReturnTo
= $request->getVal( 'returnto' );
54 $this->mCookieCheck
= $request->getVal( 'wpCookieCheck' );
55 $this->mPosted
= $request->wasPosted();
56 $this->mCreateaccount
= $request->getCheck( 'wpCreateaccount' );
57 $this->mCreateaccountMail
= $request->getCheck( 'wpCreateaccountMail' )
59 $this->mMailmypassword
= $request->getCheck( 'wpMailmypassword' )
61 $this->mLoginattempt
= $request->getCheck( 'wpLoginattempt' );
62 $this->mAction
= $request->getVal( 'action' );
63 $this->mRemember
= $request->getCheck( 'wpRemember' );
64 $this->mLanguage
= $request->getText( 'uselang' );
66 if( $wgEnableEmail ) {
67 $this->mEmail
= $request->getText( 'wpEmail' );
71 if( $wgAllowRealName ) {
72 $this->mRealName
= $request->getText( 'wpRealName' );
74 $this->mRealName
= '';
77 if( !$wgAuth->validDomain( $this->mDomain
) ) {
78 $this->mDomain
= 'invaliddomain';
80 $wgAuth->setDomain( $this->mDomain
);
82 # When switching accounts, it sucks to get automatically logged out
83 if( $this->mReturnTo
== $wgLang->specialPage( 'Userlogout' ) ) {
84 $this->mReturnTo
= '';
89 if ( !is_null( $this->mCookieCheck
) ) {
90 $this->onCookieRedirectCheck( $this->mCookieCheck
);
92 } else if( $this->mPosted
) {
93 if( $this->mCreateaccount
) {
94 return $this->addNewAccount();
95 } else if ( $this->mCreateaccountMail
) {
96 return $this->addNewAccountMailPassword();
97 } else if ( $this->mMailmypassword
) {
98 return $this->mailPassword();
99 } else if ( ( 'submitlogin' == $this->mAction
) ||
$this->mLoginattempt
) {
100 return $this->processLogin();
103 $this->mainLoginForm( '' );
109 function addNewAccountMailPassword() {
112 if ('' == $this->mEmail
) {
113 $this->mainLoginForm( wfMsg( 'noemail', htmlspecialchars( $this->mName
) ) );
117 $u = $this->addNewaccountInternal();
123 // Wipe the initial password and mail a temporary one
124 $u->setPassword( null );
126 $result = $this->mailPasswordInternal( $u, false, 'createaccount-title', 'createaccount-text' );
128 wfRunHooks( 'AddNewAccount', array( $u ) );
130 $wgOut->setPageTitle( wfMsg( 'accmailtitle' ) );
131 $wgOut->setRobotpolicy( 'noindex,nofollow' );
132 $wgOut->setArticleRelated( false );
134 if( WikiError
::isError( $result ) ) {
135 $this->mainLoginForm( wfMsg( 'mailerror', $result->getMessage() ) );
137 $wgOut->addWikiText( wfMsg( 'accmailtext', $u->getName(), $u->getEmail() ) );
138 $wgOut->returnToMain( false );
147 function addNewAccount() {
148 global $wgUser, $wgEmailAuthentication;
150 # Create the account and abort if there's a problem doing so
151 $u = $this->addNewAccountInternal();
155 # If we showed up language selection links, and one was in use, be
156 # smart (and sensible) and save that language as the user's preference
157 global $wgLoginLanguageSelector;
158 if( $wgLoginLanguageSelector && $this->mLanguage
)
159 $u->setOption( 'language', $this->mLanguage
);
161 # Save user settings and send out an email authentication message if needed
163 if( $wgEmailAuthentication && User
::isValidEmailAddr( $u->getEmail() ) ) {
165 $error = $u->sendConfirmationMail();
166 if( WikiError
::isError( $error ) ) {
167 $wgOut->addWikiText( wfMsg( 'confirmemail_sendfailed', $error->getMessage() ) );
169 $wgOut->addWikiText( wfMsg( 'confirmemail_oncreate' ) );
173 # If not logged in, assume the new account as the current one and set session cookies
174 # then show a "welcome" message or a "need cookies" message as needed
175 if( $wgUser->isAnon() ) {
177 $wgUser->setCookies();
178 wfRunHooks( 'AddNewAccount', array( $wgUser ) );
179 if( $this->hasSessionCookie() ) {
180 return $this->successfulLogin( wfMsg( 'welcomecreation', $wgUser->getName() ), false );
182 return $this->cookieRedirectCheck( 'new' );
185 # Confirm that the account was created
187 $self = SpecialPage
::getTitleFor( 'Userlogin' );
188 $wgOut->setPageTitle( wfMsgHtml( 'accountcreated' ) );
189 $wgOut->setArticleRelated( false );
190 $wgOut->setRobotPolicy( 'noindex,nofollow' );
191 $wgOut->addHtml( wfMsgWikiHtml( 'accountcreatedtext', $u->getName() ) );
192 $wgOut->returnToMain( false, $self );
193 wfRunHooks( 'AddNewAccount', array( $u ) );
201 function addNewAccountInternal() {
202 global $wgUser, $wgOut;
203 global $wgEnableSorbs, $wgProxyWhitelist;
204 global $wgMemc, $wgAccountCreationThrottle;
205 global $wgAuth, $wgMinimalPasswordLength;
206 global $wgEmailConfirmToEdit;
208 // If the user passes an invalid domain, something is fishy
209 if( !$wgAuth->validDomain( $this->mDomain
) ) {
210 $this->mainLoginForm( wfMsg( 'wrongpassword' ) );
214 // If we are not allowing users to login locally, we should
215 // be checking to see if the user is actually able to
216 // authenticate to the authentication server before they
217 // create an account (otherwise, they can create a local account
218 // and login as any domain user). We only need to check this for
219 // domains that aren't local.
220 if( 'local' != $this->mDomain
&& '' != $this->mDomain
) {
221 if( !$wgAuth->canCreateAccounts() && ( !$wgAuth->userExists( $this->mName
) ||
!$wgAuth->authenticate( $this->mName
, $this->mPassword
) ) ) {
222 $this->mainLoginForm( wfMsg( 'wrongpassword' ) );
227 if ( wfReadOnly() ) {
228 $wgOut->readOnlyPage();
233 if ( !$wgUser->isAllowed( 'createaccount' ) ) {
234 $this->userNotPrivilegedMessage();
236 } elseif ( $wgUser->isBlockedFromCreateAccount() ) {
237 $this->userBlockedMessage();
242 if ( $wgEnableSorbs && !in_array( $ip, $wgProxyWhitelist ) &&
243 $wgUser->inSorbsBlacklist( $ip ) )
245 $this->mainLoginForm( wfMsg( 'sorbs_create_account_reason' ) . ' (' . htmlspecialchars( $ip ) . ')' );
249 # Now create a dummy user ($u) and check if it is valid
250 $name = trim( $this->mName
);
251 $u = User
::newFromName( $name, 'creatable' );
252 if ( is_null( $u ) ) {
253 $this->mainLoginForm( wfMsg( 'noname' ) );
257 if ( 0 != $u->idForName() ) {
258 $this->mainLoginForm( wfMsg( 'userexists' ) );
262 if ( 0 != strcmp( $this->mPassword
, $this->mRetype
) ) {
263 $this->mainLoginForm( wfMsg( 'badretype' ) );
267 # check for minimal password length
268 if ( !$u->isValidPassword( $this->mPassword
) ) {
269 if ( !$this->mCreateaccountMail
) {
270 $this->mainLoginForm( wfMsg( 'passwordtooshort', $wgMinimalPasswordLength ) );
273 # do not force a password for account creation by email
274 # set pseudo password, it will be replaced later by a random generated password
275 $this->mPassword
= '-';
279 # if you need a confirmed email address to edit, then obviously you need an email address.
280 if ( $wgEmailConfirmToEdit && empty( $this->mEmail
) ) {
281 $this->mainLoginForm( wfMsg( 'noemailtitle' ) );
285 if( !empty( $this->mEmail
) && !User
::isValidEmailAddr( $this->mEmail
) ) {
286 $this->mainLoginForm( wfMsg( 'invalidemailaddress' ) );
290 # Set some additional data so the AbortNewAccount hook can be
291 # used for more than just username validation
292 $u->setEmail( $this->mEmail
);
293 $u->setRealName( $this->mRealName
);
296 if( !wfRunHooks( 'AbortNewAccount', array( $u, &$abortError ) ) ) {
297 // Hook point to add extra creation throttles and blocks
298 wfDebug( "LoginForm::addNewAccountInternal: a hook blocked creation\n" );
299 $this->mainLoginForm( $abortError );
303 if ( $wgAccountCreationThrottle && $wgUser->isPingLimitable() ) {
304 $key = wfMemcKey( 'acctcreate', 'ip', $ip );
305 $value = $wgMemc->incr( $key );
307 $wgMemc->set( $key, 1, 86400 );
309 if ( $value > $wgAccountCreationThrottle ) {
310 $this->throttleHit( $wgAccountCreationThrottle );
315 if( !$wgAuth->addUser( $u, $this->mPassword
, $this->mEmail
, $this->mRealName
) ) {
316 $this->mainLoginForm( wfMsg( 'externaldberror' ) );
320 return $this->initUser( $u, false );
324 * Actually add a user to the database.
325 * Give it a User object that has been initialised with a name.
327 * @param $u User object.
328 * @param $autocreate boolean -- true if this is an autocreation via auth plugin
329 * @return User object.
332 function initUser( $u, $autocreate ) {
337 if ( $wgAuth->allowPasswordChange() ) {
338 $u->setPassword( $this->mPassword
);
341 $u->setEmail( $this->mEmail
);
342 $u->setRealName( $this->mRealName
);
345 $wgAuth->initUser( $u, $autocreate );
347 $u->setOption( 'rememberpassword', $this->mRemember ?
1 : 0 );
351 $ssUpdate = new SiteStatsUpdate( 0, 0, 0, 0, 1 );
352 $ssUpdate->doUpdate();
358 * Internally authenticate the login request.
360 * This may create a local account as a side effect if the
361 * authentication plugin allows transparent local account
366 function authenticateUserData() {
367 global $wgUser, $wgAuth;
368 if ( '' == $this->mName
) {
369 return self
::NO_NAME
;
371 $u = User
::newFromName( $this->mName
);
372 if( is_null( $u ) ||
!User
::isUsableName( $u->getName() ) ) {
373 return self
::ILLEGAL
;
375 if ( 0 == $u->getID() ) {
378 * If the external authentication plugin allows it,
379 * automatically create a new account for users that
380 * are externally defined but have not yet logged in.
382 if ( $wgAuth->autoCreate() && $wgAuth->userExists( $u->getName() ) ) {
383 if ( $wgAuth->authenticate( $u->getName(), $this->mPassword
) ) {
384 $u = $this->initUser( $u, true );
386 return self
::WRONG_PLUGIN_PASS
;
389 return self
::NOT_EXISTS
;
395 // Give general extensions, such as a captcha, a chance to abort logins
396 $abort = self
::ABORTED
;
397 if( !wfRunHooks( 'AbortLogin', array( $u, $this->mPassword
, &$abort ) ) ) {
401 if (!$u->checkPassword( $this->mPassword
)) {
402 if( $u->checkTemporaryPassword( $this->mPassword
) ) {
403 // The e-mailed temporary password should not be used
404 // for actual logins; that's a very sloppy habit,
405 // and insecure if an attacker has a few seconds to
406 // click "search" on someone's open mail reader.
408 // Allow it to be used only to reset the password
409 // a single time to a new value, which won't be in
410 // the user's e-mail archives.
412 // For backwards compatibility, we'll still recognize
413 // it at the login form to minimize surprises for
414 // people who have been logging in with a temporary
415 // password for some time.
417 // As a side-effect, we can authenticate the user's
418 // e-mail address if it's not already done, since
419 // the temporary password was sent via e-mail.
421 if( !$u->isEmailConfirmed() ) {
425 // At this point we just return an appropriate code
426 // indicating that the UI should show a password
427 // reset form; bot interfaces etc will probably just
428 // fail cleanly here.
430 $retval = self
::RESET_PASS
;
432 $retval = '' == $this->mPassword ? self
::EMPTY_PASS
: self
::WRONG_PASS
;
435 $wgAuth->updateUser( $u );
438 $retval = self
::SUCCESS
;
440 wfRunHooks( 'LoginAuthenticateAudit', array( $u, $this->mPassword
, $retval ) );
444 function processLogin() {
445 global $wgUser, $wgAuth;
447 switch ($this->authenticateUserData())
450 # We've verified now, update the real record
451 if( (bool)$this->mRemember
!= (bool)$wgUser->getOption( 'rememberpassword' ) ) {
452 $wgUser->setOption( 'rememberpassword', $this->mRemember ?
1 : 0 );
453 $wgUser->saveSettings();
455 $wgUser->invalidateCache();
457 $wgUser->setCookies();
459 if( $this->hasSessionCookie() ) {
460 return $this->successfulLogin( wfMsg( 'loginsuccess', $wgUser->getName() ) );
462 return $this->cookieRedirectCheck( 'login' );
468 $this->mainLoginForm( wfMsg( 'noname' ) );
470 case self
::WRONG_PLUGIN_PASS
:
471 $this->mainLoginForm( wfMsg( 'wrongpassword' ) );
473 case self
::NOT_EXISTS
:
474 $this->mainLoginForm( wfMsg( 'nosuchuser', htmlspecialchars( $this->mName
) ) );
476 case self
::WRONG_PASS
:
477 $this->mainLoginForm( wfMsg( 'wrongpassword' ) );
479 case self
::EMPTY_PASS
:
480 $this->mainLoginForm( wfMsg( 'wrongpasswordempty' ) );
482 case self
::RESET_PASS
:
483 $this->resetLoginForm( wfMsg( 'resetpass_announce' ) );
486 wfDebugDieBacktrace( "Unhandled case value" );
490 function resetLoginForm( $error ) {
492 $wgOut->addWikiText( "<div class=\"errorbox\">$error</div>" );
493 $reset = new PasswordResetForm( $this->mName
, $this->mPassword
);
494 $reset->execute( null );
500 function mailPassword() {
501 global $wgUser, $wgOut, $wgAuth;
503 if( !$wgAuth->allowPasswordChange() ) {
504 $this->mainLoginForm( wfMsg( 'resetpass_forbidden' ) );
508 # Check against blocked IPs
509 # fixme -- should we not?
510 if( $wgUser->isBlocked() ) {
511 $this->mainLoginForm( wfMsg( 'blocked-mailpassword' ) );
515 # Check against the rate limiter
516 if( $wgUser->pingLimiter( 'mailpassword' ) ) {
517 $wgOut->rateLimited();
521 if ( '' == $this->mName
) {
522 $this->mainLoginForm( wfMsg( 'noname' ) );
525 $u = User
::newFromName( $this->mName
);
526 if( is_null( $u ) ) {
527 $this->mainLoginForm( wfMsg( 'noname' ) );
530 if ( 0 == $u->getID() ) {
531 $this->mainLoginForm( wfMsg( 'nosuchuser', $u->getName() ) );
535 # Check against password throttle
536 if ( $u->isPasswordReminderThrottled() ) {
537 global $wgPasswordReminderResendTime;
538 # Round the time in hours to 3 d.p., in case someone is specifying minutes or seconds.
539 $this->mainLoginForm( wfMsg( 'throttled-mailpassword',
540 round( $wgPasswordReminderResendTime, 3 ) ) );
544 $result = $this->mailPasswordInternal( $u, true, 'passwordremindertitle', 'passwordremindertext' );
545 if( WikiError
::isError( $result ) ) {
546 $this->mainLoginForm( wfMsg( 'mailerror', $result->getMessage() ) );
548 $this->mainLoginForm( wfMsg( 'passwordsent', $u->getName() ), 'success' );
555 * @param bool throttle
556 * @param string message name of email title
557 * @param string message name of email text
558 * @return mixed true on success, WikiError on failure
561 function mailPasswordInternal( $u, $throttle = true, $emailTitle = 'passwordremindertitle', $emailText = 'passwordremindertext' ) {
562 global $wgCookiePath, $wgCookieDomain, $wgCookiePrefix, $wgCookieSecure;
563 global $wgServer, $wgScript;
565 if ( '' == $u->getEmail() ) {
566 return new WikiError( wfMsg( 'noemail', $u->getName() ) );
569 $np = $u->randomPassword();
570 $u->setNewpassword( $np, $throttle );
572 setcookie( "{$wgCookiePrefix}Token", '', time() - 3600, $wgCookiePath, $wgCookieDomain, $wgCookieSecure );
577 if ( '' == $ip ) { $ip = '(Unknown)'; }
579 $m = wfMsg( $emailText, $ip, $u->getName(), $np, $wgServer . $wgScript );
580 $result = $u->sendMail( wfMsg( $emailTitle ), $m );
587 * @param string $msg Message that will be shown on success
588 * @param bool $auto Toggle auto-redirect to main page; default true
591 function successfulLogin( $msg, $auto = true ) {
595 # Run any hooks; ignore results
597 wfRunHooks('UserLoginComplete', array(&$wgUser));
599 $wgOut->setPageTitle( wfMsg( 'loginsuccesstitle' ) );
600 $wgOut->setRobotpolicy( 'noindex,nofollow' );
601 $wgOut->setArticleRelated( false );
602 $wgOut->addWikiText( $msg );
603 if ( !empty( $this->mReturnTo
) ) {
604 $wgOut->returnToMain( $auto, $this->mReturnTo
);
606 $wgOut->returnToMain( $auto );
611 function userNotPrivilegedMessage() {
614 $wgOut->setPageTitle( wfMsg( 'whitelistacctitle' ) );
615 $wgOut->setRobotpolicy( 'noindex,nofollow' );
616 $wgOut->setArticleRelated( false );
618 $wgOut->addWikiText( wfMsg( 'whitelistacctext' ) );
620 $wgOut->returnToMain( false );
624 function userBlockedMessage() {
625 global $wgOut, $wgUser;
627 # Let's be nice about this, it's likely that this feature will be used
628 # for blocking large numbers of innocent people, e.g. range blocks on
629 # schools. Don't blame it on the user. There's a small chance that it
630 # really is the user's fault, i.e. the username is blocked and they
631 # haven't bothered to log out before trying to create an account to
632 # evade it, but we'll leave that to their guilty conscience to figure
635 $wgOut->setPageTitle( wfMsg( 'cantcreateaccounttitle' ) );
636 $wgOut->setRobotpolicy( 'noindex,nofollow' );
637 $wgOut->setArticleRelated( false );
640 $blocker = User
::whoIs( $wgUser->mBlock
->mBy
);
641 $block_reason = $wgUser->mBlock
->mReason
;
643 $wgOut->addWikiText( wfMsg( 'cantcreateaccount-text', $ip, $block_reason, $blocker ) );
644 $wgOut->returnToMain( false );
650 function mainLoginForm( $msg, $msgtype = 'error' ) {
651 global $wgUser, $wgOut, $wgAllowRealName, $wgEnableEmail;
652 global $wgCookiePrefix, $wgAuth, $wgLoginLanguageSelector;
653 global $wgAuth, $wgEmailConfirmToEdit;
655 if ( $this->mType
== 'signup' ) {
656 if ( !$wgUser->isAllowed( 'createaccount' ) ) {
657 $this->userNotPrivilegedMessage();
659 } elseif ( $wgUser->isBlockedFromCreateAccount() ) {
660 $this->userBlockedMessage();
665 if ( '' == $this->mName
) {
666 if ( $wgUser->isLoggedIn() ) {
667 $this->mName
= $wgUser->getName();
669 $this->mName
= isset( $_COOKIE[$wgCookiePrefix.'UserName'] ) ?
$_COOKIE[$wgCookiePrefix.'UserName'] : null;
673 $titleObj = SpecialPage
::getTitleFor( 'Userlogin' );
675 if ( $this->mType
== 'signup' ) {
676 $template = new UsercreateTemplate();
677 $q = 'action=submitlogin&type=signup';
678 $linkq = 'type=login';
679 $linkmsg = 'gotaccount';
681 $template = new UserloginTemplate();
682 $q = 'action=submitlogin&type=login';
683 $linkq = 'type=signup';
684 $linkmsg = 'nologin';
687 if ( !empty( $this->mReturnTo
) ) {
688 $returnto = '&returnto=' . wfUrlencode( $this->mReturnTo
);
693 # Pass any language selection on to the mode switch link
694 if( $wgLoginLanguageSelector && $this->mLanguage
)
695 $linkq .= '&uselang=' . $this->mLanguage
;
697 $link = '<a href="' . htmlspecialchars ( $titleObj->getLocalUrl( $linkq ) ) . '">';
698 $link .= wfMsgHtml( $linkmsg . 'link' ); # Calling either 'gotaccountlink' or 'nologinlink'
701 # Don't show a "create account" link if the user can't
702 if( $this->showCreateOrLoginLink( $wgUser ) )
703 $template->set( 'link', wfMsgHtml( $linkmsg, $link ) );
705 $template->set( 'link', '' );
707 $template->set( 'header', '' );
708 $template->set( 'name', $this->mName
);
709 $template->set( 'password', $this->mPassword
);
710 $template->set( 'retype', $this->mRetype
);
711 $template->set( 'email', $this->mEmail
);
712 $template->set( 'realname', $this->mRealName
);
713 $template->set( 'domain', $this->mDomain
);
715 $template->set( 'action', $titleObj->getLocalUrl( $q ) );
716 $template->set( 'message', $msg );
717 $template->set( 'messagetype', $msgtype );
718 $template->set( 'createemail', $wgEnableEmail && $wgUser->isLoggedIn() );
719 $template->set( 'userealname', $wgAllowRealName );
720 $template->set( 'useemail', $wgEnableEmail );
721 $template->set( 'emailrequired', $wgEmailConfirmToEdit );
722 $template->set( 'canreset', $wgAuth->allowPasswordChange() );
723 $template->set( 'remember', $wgUser->getOption( 'rememberpassword' ) or $this->mRemember
);
725 # Prepare language selection links as needed
726 if( $wgLoginLanguageSelector ) {
727 $template->set( 'languages', $this->makeLanguageSelector() );
728 if( $this->mLanguage
)
729 $template->set( 'uselang', $this->mLanguage
);
732 // Give authentication and captcha plugins a chance to modify the form
733 $wgAuth->modifyUITemplate( $template );
734 if ( $this->mType
== 'signup' ) {
735 wfRunHooks( 'UserCreateForm', array( &$template ) );
737 wfRunHooks( 'UserLoginForm', array( &$template ) );
740 $wgOut->setPageTitle( wfMsg( 'userlogin' ) );
741 $wgOut->setRobotpolicy( 'noindex,nofollow' );
742 $wgOut->setArticleRelated( false );
743 $wgOut->disallowUserJs(); // just in case...
744 $wgOut->addTemplate( $template );
750 function showCreateOrLoginLink( &$user ) {
751 if( $this->mType
== 'signup' ) {
753 } elseif( $user->isAllowed( 'createaccount' ) ) {
761 * Check if a session cookie is present.
763 * This will not pick up a cookie set during _this_ request, but is
764 * meant to ensure that the client is returning the cookie which was
765 * set on a previous pass through the system.
769 function hasSessionCookie() {
770 global $wgDisableCookieCheck, $wgRequest;
771 return $wgDisableCookieCheck ?
true : $wgRequest->checkSessionCookie();
777 function cookieRedirectCheck( $type ) {
780 $titleObj = SpecialPage
::getTitleFor( 'Userlogin' );
781 $check = $titleObj->getFullURL( 'wpCookieCheck='.$type );
783 return $wgOut->redirect( $check );
789 function onCookieRedirectCheck( $type ) {
792 if ( !$this->hasSessionCookie() ) {
793 if ( $type == 'new' ) {
794 return $this->mainLoginForm( wfMsg( 'nocookiesnew' ) );
795 } else if ( $type == 'login' ) {
796 return $this->mainLoginForm( wfMsg( 'nocookieslogin' ) );
799 return $this->mainLoginForm( wfMsg( 'error' ) );
802 return $this->successfulLogin( wfMsg( 'loginsuccess', $wgUser->getName() ) );
809 function throttleHit( $limit ) {
812 $wgOut->addWikiText( wfMsg( 'acct_creation_throttle_hit', $limit ) );
816 * Produce a bar of links which allow the user to select another language
817 * during login/registration but retain "returnto"
821 function makeLanguageSelector() {
822 $msg = wfMsgForContent( 'loginlanguagelinks' );
823 if( $msg != '' && !wfEmptyMsg( 'loginlanguagelinks', $msg ) ) {
824 $langs = explode( "\n", $msg );
826 foreach( $langs as $lang ) {
827 $lang = trim( $lang, '* ' );
828 $parts = explode( '|', $lang );
829 if (count($parts) >= 2) {
830 $links[] = $this->makeLanguageSelectorLink( $parts[0], $parts[1] );
833 return count( $links ) > 0 ?
wfMsgHtml( 'loginlanguagelabel', implode( ' | ', $links ) ) : '';
840 * Create a language selector link for a particular language
841 * Links back to this page preserving type and returnto
843 * @param $text Link text
844 * @param $lang Language code
846 function makeLanguageSelectorLink( $text, $lang ) {
848 $self = SpecialPage
::getTitleFor( 'Userlogin' );
849 $attr[] = 'uselang=' . $lang;
850 if( $this->mType
== 'signup' )
851 $attr[] = 'type=signup';
852 if( $this->mReturnTo
)
853 $attr[] = 'returnto=' . $this->mReturnTo
;
854 $skin = $wgUser->getSkin();
855 return $skin->makeKnownLinkObj( $self, htmlspecialchars( $text ), implode( '&', $attr ) );