Force email confirmation in Mediawiki 1.9
Before proceeding to this article, have you tried the following links?
If non of the above answers the problem, you may try this solution.
How to check if a registered user has confirmed his registration email? Here is a simple modification I made. It checks if the user has confirmed his/her email before logging in. You may use it anytime at your own risk. If there are any bugs or it has been helpful, tell and share what you think here
Affected files are:
/wiki/languages/messages/MessagesEn.php
/wiki/includes/SpecialUserLogin.php
For Messages.php, I only added/edited the ffg:
-
'not_authenticated' => 'Please verify your email address and try again.',
-
'confirmemail_oncreate' => 'A confirmation code was sent to your e-mail address.
-
Please verify it before you can edit any page.',
-
)
-
-
For the <strong>SpecialUserLogin.php</strong>, here are the changes
-
-
class LoginForm {
-
// Added for confirmation error in login
-
const NO_AUTH = 8;
-
-
function addNewAccount() {
-
-
# Create the account and abort if there's a problem doing so
-
$u = $this->addNewAccountInternal();
-
if( $u == NULL )
-
return;
-
-
# If we showed up language selection links, and one was in use, be
-
# smart (and sensible) and save that language as the user's preference
-
global $wgLoginLanguageSelector;
-
if( $wgLoginLanguageSelector && $this->mLanguage )
-
$u->setOption( 'language', $this->mLanguage );
-
-
# Save user settings and send out an email authentication message if needed
-
if( $wgEmailAuthentication && User::isValidEmailAddr( $u->getEmail() ) ) {
-
//Position it here
-
$u->saveSettings();
-
global $wgOut;
-
$error = $u->sendConfirmationMail();
-
if( WikiError::isError( $error ) ) {
-
$wgOut->addWikiText( wfMsg( 'confirmemail_sendfailed', $error->getMessage() ) );
-
} else {
-
$wgOut->addWikiText( wfMsg( 'confirmemail_oncreate' ) );
-
}
-
}
-
-
//removed the other unneccary conditions
-
global $wgOut;
-
$self = SpecialPage::getTitleFor( 'Userlogin' );
-
$wgOut->setPageTitle( wfMsgHtml( 'accountcreated' ) );
-
$wgOut->setArticleRelated( false );
-
$wgOut->setRobotPolicy( 'noindex,nofollow' );
-
$wgOut->addHtml( wfMsgWikiHtml( 'accountcreatedtext', $u->getName() ) );
-
$wgOut->returnToMain( $self->getPrefixedText() );
-
return true;
-
}
-
-
function authenticateUserData() {
-
# code before the changes
-
if ( 0 == $u->getID() ) {
-
...
-
} else {
-
$u->load();
-
}
-
-
// check if the user has confirmed his/her email
-
if( !$u->isEmailConfirmed() ) {
-
return self::NO_AUTH;
-
}
-
-
#code after the changes
-
if (!$u->checkPassword( $this->mPassword )) {
-
if( $u->checkTemporaryPassword( $this->mPassword ) ) {
-
}
-
-
function processLogin() {
-
...
-
# code before the changes
-
case self::RESET_PASS:
-
$this->resetLoginForm( wfMsg( 'resetpass_announce' ) );
-
break;
-
case self::NO_AUTH:
-
$this->mainLoginForm( wfMsg( 'not_authenticated' ) );
-
break;
-
# code after the changes
-
default:
-
wfDebugDieBacktrace( "Unhandled case value" );
-
}
-
}
Improvement:
In the Special:Confirm, you may want to make this work without having to log in. I haven't had the time to tweak that. If you do have the solution, please share them here





Recent Comments