*/
function addNewAccount() {
global $wgUser, $wgEmailAuthentication;
-
+
+ # Create the account and abort if there's a problem doing so
$u = $this->addNewAccountInternal();
-
- if ($u == NULL) {
+ if( $u == NULL )
return;
- }
-
- $wgUser = $u;
- $wgUser->setCookies();
-
- $wgUser->saveSettings();
- if( $wgEmailAuthentication && $wgUser->isValidEmailAddr( $wgUser->getEmail() ) ) {
- $wgUser->sendConfirmationMail();
- }
-
- wfRunHooks( 'AddNewAccount', array( $u ) );
-
- if( $this->hasSessionCookie() ) {
- return $this->successfulLogin( wfMsg( 'welcomecreation', $wgUser->getName() ), false );
+
+ # Save user settings and send out an email authentication message if needed
+ $u->saveSettings();
+ if( $wgEmailAuthentication && User::isValidEmailAddr( $u->getEmail() ) )
+ $u->sendConfirmationMail();
+
+ # If not logged in, assume the new account as the current one and set session cookies
+ # then show a "welcome" message or a "need cookies" message as needed
+ if( $wgUser->isAnon() ) {
+ $wgUser = $u;
+ $wgUser->setCookies();
+ wfRunHooks( 'AddNewAccount', array( $wgUser ) );
+ if( $this->hasSessionCookie() ) {
+ return $this->successfulLogin( wfMsg( 'welcomecreation', $wgUser->getName() ), false );
+ } else {
+ return $this->cookieRedirectCheck( 'new' );
+ }
} else {
- return $this->cookieRedirectCheck( 'new' );
+ # Confirm that the account was created
+ global $wgOut;
+ $skin = $wgUser->getSkin();
+ $self = Title::makeTitle( NS_SPECIAL, 'Userlogin' );
+ $wgOut->setPageTitle( wfMsgHtml( 'accountcreated' ) );
+ $wgOut->setArticleRelated( false );
+ $wgOut->setRobotPolicy( 'noindex,nofollow' );
+ $wgOut->addHtml( wfMsgWikiHtml( 'accountcreatedtext', $u->getName() ) );
+ $wgOut->returnToMain( $self->getPrefixedText() );
+ wfRunHooks( 'AddNewAccount', array( $u ) );
+ return true;
}
}
* @private
*/
function mailPassword() {
+ global $wgUser, $wgOut;
+
+ # Check against the rate limiter
+ if( $wgUser->pingLimiter( 'mailpassword' ) ) {
+ $wgOut->rateLimited();
+ return;
+ }
+
if ( '' == $this->mName ) {
$this->mainLoginForm( wfMsg( 'noname' ) );
return;
*/
function mailPasswordInternal( $u ) {
global $wgCookiePath, $wgCookieDomain, $wgCookiePrefix, $wgCookieSecure;
+ global $wgServer, $wgScript;
if ( '' == $u->getEmail() ) {
return wfMsg( 'noemail', $u->getName() );
$ip = wfGetIP();
if ( '' == $ip ) { $ip = '(Unknown)'; }
- $m = wfMsg( 'passwordremindertext', $ip, $u->getName(), $np );
+ $m = wfMsg( 'passwordremindertext', $ip, $u->getName(), $np, $wgServer . $wgScript );
$result = $u->sendMail( wfMsg( 'passwordremindertitle' ), $m );
return $result;
global $wgCookiePrefix;
global $wgAuth;
+ if ( $this->mType == 'signup' && !$wgUser->isAllowedToCreateAccount() ) {
+ $this->userNotPrivilegedMessage();
+ return;
+ }
+
if ( '' == $this->mName ) {
if ( $wgUser->isLoggedIn() ) {
$this->mName = $wgUser->getName();
$template->set( 'action', $titleObj->getLocalUrl( $q ) );
$template->set( 'message', $msg );
$template->set( 'messagetype', $msgtype );
- $template->set( 'create', $wgUser->isAllowedToCreateAccount() );
$template->set( 'createemail', $wgEnableEmail && $wgUser->isLoggedIn() );
$template->set( 'userealname', $wgAllowRealName );
$template->set( 'useemail', $wgEnableEmail );