53 parent::__construct(
'ChangeEmail',
'editmyprivateinfo' );
66 return $this->
getAuthManager()->allowsPropertyChange(
'emailaddress' );
75 $out->disallowUserJs();
76 $out->addModules(
'mediawiki.special.changeemail' );
77 parent::execute(
$par );
85 if ( !$this->
getAuthManager()->allowsPropertyChange(
'emailaddress' ) ) {
93 if ( !$this->
getAuthority()->isAllowed(
'viewmyprivateinfo' ) ) {
97 parent::checkExecutePermissions( $user );
106 'label-message' =>
'username',
111 'label-message' =>
'changeemail-oldemail',
112 'default' => $user->
getEmail() ?: $this->
msg(
'changeemail-none' )->text(),
116 'label-message' =>
'changeemail-newemail',
119 'help-message' =>
'changeemail-newemail-help',
129 $form->
setId(
'mw-changeemail-form' );
139 $this->status = $this->attemptChange( $this->
getUser(), $data[
'NewEmail'] );
141 return $this->status;
147 $returnTo = $request->getVal(
'returnto' );
148 $titleObj = $returnTo !==
null ? Title::newFromText( $returnTo ) :
null;
149 if ( !$titleObj instanceof
Title ) {
150 $titleObj = Title::newMainPage();
152 $query = $request->getVal(
'returntoquery',
'' );
154 if ( $this->status->value ===
true ) {
155 $this->
getOutput()->redirect( $titleObj->getFullUrlForRedirect( $query ) );
156 } elseif ( $this->status->value ===
'eauth' ) {
157 # Notify user that a confirmation email has been sent...
161 $out->msg(
'eauthentsent', $this->getUser()->getName() )->parse()
175 private function attemptChange(
User $user, $newAddr ) {
176 if ( $newAddr !==
'' && !Sanitizer::validateEmail( $newAddr ) ) {
177 return Status::newFatal(
'invalidemailaddress' );
181 if ( $newAddr === $oldAddr ) {
182 return Status::newFatal(
'changeemail-nochange' );
185 if ( strlen( $newAddr ) > 255 ) {
186 return Status::newFatal(
'changeemail-maxlength' );
191 if ( $newAddr !==
'' ) {
194 if ( !$status->
isGood() ) {
195 return Status::wrap( $status );
200 $status = $userLatest->setEmailWithConfirmation( $newAddr );
201 if ( !$status->
isGood() ) {
205 LoggerFactory::getInstance(
'authentication' )->info(
206 'Changing email address for {user} from {oldemail} to {newemail}', [
207 'user' => $userLatest->getName(),
208 'oldemail' => $oldAddr,
209 'newemail' => $newAddr,
213 $this->
getHookRunner()->onPrefsEmailAudit( $userLatest, $oldAddr, $newAddr );
215 $userLatest->saveSettings();
230class_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 sub-page 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.
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.
requireNamedUser( $reasonMsg='exception-nologin-text', $titleMsg='exception-nologin')
If the user is not logged in or is a temporary user, throws UserNotLoggedIn.
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.