- if ( $wgEnableEmail ) {
- $newaddr = $formData['emailaddress'];
- $oldaddr = $wgUser->getEmail();
- if ( ( $newaddr != '' ) && ( $newaddr != $oldaddr ) ) {
- # the user has supplied a new email address on the login page
- # new behaviour: set this new emailaddr from login-page into user database record
- $wgUser->setEmail( $newaddr );
- # but flag as "dirty" = unauthenticated
- $wgUser->invalidateEmail();
- if ( $wgEmailAuthentication ) {
- # Mail a temporary password to the dirty address.
- # User can come back through the confirmation URL to re-enable email.
- $result = $wgUser->sendConfirmationMail( $oldaddr != '' );
- if ( WikiError::isError( $result ) ) {
- return wfMsg( 'mailerror', htmlspecialchars( $result->getMessage() ) );
- } elseif ( $entryPoint == 'ui' ) {
- $result = 'eauth';
- }
- }
- } else {
- $wgUser->setEmail( $newaddr );
- }
- if ( $oldaddr != $newaddr ) {
- wfRunHooks( 'PrefsEmailAudit', array( $wgUser, $oldaddr, $newaddr ) );
- }
- }
-