44 parent::__construct(
'ChangeEmail',
'editmyprivateinfo' );
57 return $this->
getAuthManager()->allowsPropertyChange(
'emailaddress' );
66 $out->disallowUserJs();
67 $out->addModules(
'mediawiki.special.changeemail' );
68 parent::execute(
$par );
76 if ( !$this->
getAuthManager()->allowsPropertyChange(
'emailaddress' ) ) {
84 if ( !$this->
getAuthority()->isAllowed(
'viewmyprivateinfo' ) ) {
88 parent::checkExecutePermissions( $user );
97 'label-message' =>
'username',
102 'label-message' =>
'changeemail-oldemail',
103 'default' => $user->
getEmail() ?: $this->
msg(
'changeemail-none' )->text(),
107 'label-message' =>
'changeemail-newemail',
110 'help-message' =>
'changeemail-newemail-help',
120 $form->
setId(
'mw-changeemail-form' );
130 $this->status = $this->attemptChange( $this->
getUser(), $data[
'NewEmail'] );
132 return $this->status;
138 $returnTo = $request->getVal(
'returnto' );
139 $titleObj = $returnTo !==
null ? Title::newFromText( $returnTo ) :
null;
140 if ( !$titleObj instanceof
Title ) {
141 $titleObj = Title::newMainPage();
143 $query = $request->getVal(
'returntoquery',
'' );
145 if ( $this->status->value ===
true ) {
146 $this->
getOutput()->redirect( $titleObj->getFullUrlForRedirect( $query ) );
147 } elseif ( $this->status->value ===
'eauth' ) {
148 # Notify user that a confirmation email has been sent...
152 $out->msg(
'eauthentsent', $this->getUser()->getName() )->parse()
166 private function attemptChange(
User $user, $newAddr ) {
167 if ( $newAddr !==
'' && !Sanitizer::validateEmail( $newAddr ) ) {
168 return Status::newFatal(
'invalidemailaddress' );
172 if ( $newAddr === $oldAddr ) {
176 if ( strlen( $newAddr ) > 255 ) {
182 if ( $newAddr !==
'' && $user->
pingLimiter(
'changeemail' ) ) {
187 $status = $userLatest->setEmailWithConfirmation( $newAddr );
188 if ( !$status->
isGood() ) {
192 LoggerFactory::getInstance(
'authentication' )->info(
193 'Changing email address for {user} from {oldemail} to {newemail}', [
194 'user' => $userLatest->getName(),
195 'oldemail' => $oldAddr,
196 'newemail' => $newAddr,
200 $this->
getHookRunner()->onPrefsEmailAudit( $userLatest, $oldAddr, $newAddr );
202 $userLatest->saveSettings();
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.
Show an error when a user tries to do something they do not have the necessary permissions for.
Let users change their email address.
doesWrites()
Indicates whether this special page may perform database writes.
requiresUnblock()
Whether this action cannot be executed by a blocked user, default to requiresPost()
getDisplayFormat()
Get display format for the form.
onSuccess()
Do something exciting on successful processing of the form, most likely to show a confirmation messag...
alterForm(HTMLForm $form)
Play with the HTMLForm if you need to more substantially.
getFormFields()
Get an HTMLForm descriptor array.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
checkExecutePermissions(User $user)
Called from execute() to check if the given user can perform this action.
__construct(AuthManager $authManager)
execute( $par)
Main execution point.
getLoginSecurityLevel()
Tells if the special page does something security-sensitive and needs extra defense against a stolen ...
onSubmit(array $data)
Process the form on submission.
getName()
Get the name of this Special Page.
getOutput()
Get the OutputPage being used for this instance.
getUser()
Shortcut to get the User executing this instance.
requireNamedUser( $reasonMsg='exception-nologin-text', $titleMsg='exception-nologin')
If the user is not logged in or is a temporary user, throws UserNotLoggedIn.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getAuthority()
Shortcut to get the Authority executing this instance.
getRequest()
Get the WebRequest being used for this instance.
setAuthManager(AuthManager $authManager)
Set the injected AuthManager from the special page constructor.
static newFatal( $message,... $parameters)
Factory function for fatal errors.
isGood()
Returns whether the operation completed and didn't have any error or warnings.
Generic operation result class Has warning/error list, boolean status and arbitrary value.
getName()
Get the user name, or the IP of an anonymous user.
pingLimiter( $action='edit', $incrBy=1)
Primitive rate limits: enforce maximum actions per time period to put a brake on flooding.
getEmail()
Get the user's e-mail address.
getInstanceForUpdate()
Get a new instance of this user that was loaded from the primary DB via a locking read.