50 parent::__construct(
'ChangeEmail',
'editmyprivateinfo' );
63 return $this->
getAuthManager()->allowsPropertyChange(
'emailaddress' );
72 $out->disallowUserJs();
73 $out->addModules(
'mediawiki.special.changeemail' );
74 parent::execute(
$par );
82 if ( !$this->
getAuthManager()->allowsPropertyChange(
'emailaddress' ) ) {
90 if ( !$this->
getAuthority()->isAllowed(
'viewmyprivateinfo' ) ) {
94 parent::checkExecutePermissions( $user );
103 'label-message' =>
'username',
108 'label-message' =>
'changeemail-oldemail',
109 'default' => $user->
getEmail() ?: $this->
msg(
'changeemail-none' )->text(),
113 'label-message' =>
'changeemail-newemail',
116 'help-message' =>
'changeemail-newemail-help',
126 $form->
setId(
'mw-changeemail-form' );
136 $this->status = $this->attemptChange( $this->
getUser(), $data[
'NewEmail'] );
138 return $this->status;
144 $returnTo = $request->getVal(
'returnto' );
145 $titleObj = $returnTo !==
null ? Title::newFromText( $returnTo ) :
null;
146 if ( !$titleObj instanceof
Title ) {
147 $titleObj = Title::newMainPage();
149 $query = $request->getVal(
'returntoquery',
'' );
151 if ( $this->status->value ===
true ) {
152 $this->
getOutput()->redirect( $titleObj->getFullUrlForRedirect( $query ) );
153 } elseif ( $this->status->value ===
'eauth' ) {
154 # Notify user that a confirmation email has been sent...
158 $out->msg(
'eauthentsent', $this->getUser()->getName() )->parse()
172 private function attemptChange(
User $user, $newAddr ) {
173 if ( $newAddr !==
'' && !Sanitizer::validateEmail( $newAddr ) ) {
174 return Status::newFatal(
'invalidemailaddress' );
178 if ( $newAddr === $oldAddr ) {
179 return Status::newFatal(
'changeemail-nochange' );
182 if ( strlen( $newAddr ) > 255 ) {
183 return Status::newFatal(
'changeemail-maxlength' );
188 if ( $newAddr !==
'' ) {
191 if ( !$status->
isGood() ) {
192 return Status::wrap( $status );
197 $status = $userLatest->setEmailWithConfirmation( $newAddr );
198 if ( !$status->
isGood() ) {
202 LoggerFactory::getInstance(
'authentication' )->info(
203 'Changing email address for {user} from {oldemail} to {newemail}', [
204 'user' => $userLatest->getName(),
205 'oldemail' => $oldAddr,
206 'newemail' => $newAddr,
210 $this->
getHookRunner()->onPrefsEmailAudit( $userLatest, $oldAddr, $newAddr );
212 $userLatest->saveSettings();
227class_alias( SpecialChangeEmail::class,
'SpecialChangeEmail' );
wfCgiToArray( $query)
This is the logical opposite of wfArrayToCgi(): it accepts a query string as its argument and returns...
An error page which can definitely be safely rendered using the OutputPage.
Special page which uses an HTMLForm to handle processing.
string null $par
The subpage of the special page.
getUser()
Shortcut to get the User executing this instance.
authorizeAction(?string $action=null)
Utility function for authorizing an action to be performed by the special page.
requireNamedUser( $reasonMsg='exception-nologin-text', $titleMsg='exception-nologin', bool $alwaysRedirectToLoginPage=false)
If the user is not logged in or is a temporary user, throws UserNotLoggedIn.
setAuthManager(AuthManager $authManager)
Set the injected AuthManager from the special page constructor.
getRequest()
Get the WebRequest being used for this instance.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getOutput()
Get the OutputPage being used for this instance.
getAuthority()
Shortcut to get the Authority executing this instance.
getName()
Get the canonical, unlocalized name of this special page without namespace.
Show an error when a user tries to do something they do not have the necessary permissions for.
isGood()
Returns whether the operation completed and didn't have any error or warnings.