class LoginForm {
var $mName, $mPassword, $mRetype, $mReturnto, $mCookieCheck, $mPosted;
var $mAction, $mCreateaccount, $mCreateaccountMail, $mMailmypassword;
- var $mLoginattempt, $mRemember, $mEmail;
+ var $mLoginattempt, $mRemember, $mEmail, $mDomain;
/**
* Constructor
*/
function LoginForm( &$request ) {
global $wgLang, $wgAllowRealName, $wgEnableEmail;
+ global $wgAuth;
$this->mName = $request->getText( 'wpName' );
$this->mPassword = $request->getText( 'wpPassword' );
$this->mRetype = $request->getText( 'wpRetype' );
+ $this->mDomain = $request->getText( 'wpDomain' );
$this->mReturnto = $request->getVal( 'returnto' );
$this->mCookieCheck = $request->getVal( 'wpCookieCheck' );
$this->mPosted = $request->wasPosted();
} else {
$this->mRealName = '';
}
-
+
+ if( !$wgAuth->validDomain( $this->mDomain ) ) {
+ $this->mDomain = 'invaliddomain';
+ }
+ $wgAuth->setDomain( $this->mDomain );
+
# When switching accounts, it sucks to get automatically logged out
if( $this->mReturnto == $wgLang->specialPage( 'Userlogout' ) ) {
$this->mReturnto = '';
* @access private
*/
function addNewAccount() {
- global $wgUser, $wgOut;
+ global $wgUser, $wgOut, $wgEmailAuthentication;
$u = $this->addNewAccountInternal();
$wgUser->setCookies();
$wgUser->saveSettings();
- if( $wgUser->isValidEmailAddr( $wgUser->getEmail() ) ) {
+ if( $wgEmailAuthentication && $wgUser->isValidEmailAddr( $wgUser->getEmail() ) ) {
$wgUser->sendConfirmationMail();
}
*/
function addNewAccountInternal() {
global $wgUser, $wgOut;
- global $wgMaxNameChars;
+ global $wgMaxNameChars, $wgUseLatin1, $wgEnableSorbs, $wgProxyWhitelist;
global $wgMemc, $wgAccountCreationThrottle, $wgDBname, $wgIP;
global $wgMinimalPasswordLength;
+ global $wgAuth;
+
+ // If the user passes an invalid domain, something is fishy
+ if( !$wgAuth->validDomain( $this->mDomain ) ) {
+ $this->mainLoginForm( wfMsg( 'wrongpassword' ) );
+ 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( 'local' != $this->mDomain && '' != $this->mDomain ) {
+ if( !$wgAuth->canCreateAccounts() && ( !$wgAuth->userExists( $this->mName ) || !$wgAuth->authenticate( $this->mName, $this->mPassword ) ) ) {
+ $this->mainLoginForm( wfMsg( 'wrongpassword' ) );
+ return false;
+ }
+ }
+
+
if (!$wgUser->isAllowedToCreateAccount()) {
$this->userNotPrivilegedMessage();
return false;
}
+ if ( $wgEnableSorbs && !in_array( $wgIP, $wgProxyWhitelist ) &&
+ $wgUser->inSorbsBlacklist( $wgIP ) )
+ {
+ $this->mainLoginForm( wfMsg( 'sorbs_create_account_reason' ) );
+ return;
+ }
+
+
if ( 0 != strcmp( $this->mPassword, $this->mRetype ) ) {
$this->mainLoginForm( wfMsg( 'badretype' ) );
return false;
}
}
+ if( !$wgAuth->addUser( $u, $this->mPassword ) ) {
+ $this->mainLoginForm( wfMsg( 'externaldberror' ) );
+ return false;
+ }
+
+ # Update user count
+ $ssUpdate = new SiteStatsUpdate( 0, 0, 0, 0, 1 );
+ $ssUpdate->doUpdate();
+
return $this->initUser( $u );
}
*/
function processLogin() {
global $wgUser;
+ global $wgAuth;
if ( '' == $this->mName ) {
$this->mainLoginForm( wfMsg( 'noname' ) );
}
$u->setOption( 'rememberpassword', $r );
+ $wgAuth->updateUser( $u );
+
$wgUser = $u;
$wgUser->setCookies();
$ip = $wgIP;
if ( '' == $ip ) { $ip = '(Unknown)'; }
- $m = wfMsg( 'passwordremindermailbody', $ip, $u->getName(), wfUrlencode($u->getName()), $np );
- $result = $u->sendMail( wfMsg( 'passwordremindermailsubject' ), $m );
-
+ $m = wfMsg( 'passwordremindertext', $ip, $u->getName(), $np );
+
+ $result = $u->sendMail( wfMsg( 'passwordremindertitle' ), $m );
return $result;
}
function mainLoginForm( $err ) {
global $wgUser, $wgOut, $wgLang;
global $wgDBname, $wgAllowRealName, $wgEnableEmail;
+ global $wgAuth;
if ( '' == $this->mName ) {
if ( $wgUser->isLoggedIn() ) {
$template->set( 'retype', $this->mRetype );
$template->set( 'email', $this->mEmail );
$template->set( 'realname', $this->mRealName );
+ $template->set( 'domain', $this->mDomain );
$template->set( 'action', $titleObj->getLocalUrl( $q ) );
$template->set( 'error', $err );
$template->set( 'userealname', $wgAllowRealName );
$template->set( 'useemail', $wgEnableEmail );
$template->set( 'remember', $wgUser->getOption( 'rememberpassword' ) or $this->mRemember );
+ $wgAuth->modifyUITemplate( $template );
$wgOut->setPageTitle( wfMsg( 'userlogin' ) );
$wgOut->setRobotpolicy( 'noindex,nofollow' );