26 parent::__construct(
'ChangeCredentials',
'editmyprivateinfo' );
44 return AuthManager::ACTION_CHANGE;
49 $params = parent::getPreservedParams( $withToken );
51 'returnto' => $request->getVal(
'returnto' ),
52 'returntoquery' => $request->getVal(
'returntoquery' ),
68 if ( !$this->authRequests ) {
78 if ( $status ===
false || !$status->isOK() ) {
83 $response = $status->getValue();
85 switch ( $response->status ) {
86 case AuthenticationResponse::PASS:
89 case AuthenticationResponse::FAIL:
90 $this->
displayForm( Status::newFatal( $response->message ) );
93 throw new LogicException(
'invalid AuthenticationResponse' );
101 foreach ( $this->authRequests as $req ) {
102 if ( $req->getUniqueId() ===
$subPage ) {
106 if ( count( $foundReqs ) > 1 ) {
107 throw new LogicException(
'Multiple AuthenticationRequest objects with same ID!' );
109 $this->authRequests = $foundReqs;
115 array $requests, array $fieldInfo, array &$formDescriptor, $action
117 parent::onAuthChangeFormFields( $requests, $fieldInfo, $formDescriptor, $action );
120 if ( AuthenticationRequest::getRequestByClass( $this->authRequests,
121 PasswordAuthenticationRequest::class )
125 'autocomplete' =>
'new-password',
126 'placeholder-message' =>
'createacct-yourpassword-ph',
127 'help-message' =>
'createacct-useuniquepass',
130 'autocomplete' =>
'new-password',
131 'placeholder-message' =>
'createacct-yourpasswordagain-ph',
136 'baseField' =>
'password',
137 'autocomplete' =>
'username',
140 'cssclass' =>
'mw-htmlform-hidden-field',
141 'label-message' =>
'userlogin-yourname',
142 'placeholder-message' =>
'userlogin-yourname-ph',
149 if ( !static::$loadUserData ) {
152 $descriptor = parent::getAuthFormDescriptor( $requests, $action );
155 foreach ( $descriptor as &$field ) {
156 if ( $field[
'type'] ===
'password' && $field[
'name'] !==
'retype' ) {
158 if ( isset( $field[
'cssclass'] ) ) {
159 $field[
'cssclass'] .=
' mw-changecredentials-validate-password';
161 $field[
'cssclass'] =
'mw-changecredentials-validate-password';
167 $this->
getOutput()->addModules(
'mediawiki.misc-authed-ooui' );
175 $form = parent::getAuthForm( $requests, $action );
176 $req = reset( $requests );
177 $info = $req->describeCredentials();
180 Html::openElement(
'dl' )
181 . Html::element(
'dt', [], $this->
msg(
'credentialsform-provider' )->text() )
182 . Html::element(
'dd', [], $info[
'provider']->text() )
183 . Html::element(
'dt', [], $this->
msg(
'credentialsform-account' )->text() )
184 . Html::element(
'dd', [], $info[
'account']->text() )
185 . Html::closeElement(
'dl' )
189 $form->setSubmitTextMsg( static::$messagePrefix .
'-submit' );
190 $form->showCancel()->setCancelTarget( $this->
getReturnUrl() ?: Title::newMainPage() );
204 if ( static::$loadUserData ) {
205 $requests = AuthenticationRequest::loadRequestsFromSubmission( $this->authRequests, $data );
211 return Status::newGood( $response );
221 $out->addHTML( $error->parse() );
224 $groupedRequests = [];
225 foreach ( $this->authRequests as $req ) {
226 $info = $req->describeCredentials();
227 $groupedRequests[$info[
'provider']->text()][] = $req;
231 $out->addHTML( Html::openElement(
'dl' ) );
232 foreach ( $groupedRequests as $group => $members ) {
233 $out->addHTML( Html::element(
'dt', [], $group ) );
234 foreach ( $members as $req ) {
236 $info = $req->describeCredentials();
237 $out->addHTML( Html::rawElement(
'dd', [],
239 $this->getPageTitle( $req->getUniqueId() ),
240 $info[
'account']->text()
245 $out->addHTML( Html::closeElement(
'dl' ) );
255 SessionManager::singleton()->invalidateSessionsForUser( $user );
256 $session->setUser( $user );
260 $out->redirect( $returnUrl );
263 $out->wrapWikiMsg(
"<div class=\"successbox\">\n$1\n</div>", static::$messagePrefix
265 $out->returnToMain();
274 $returnTo = $request->getText(
'returnto' );
275 $returnToQuery = $request->getText(
'returntoquery',
'' );
281 $title = Title::newFromText( $returnTo );
282 return $title->getFullUrlForRedirect( $returnToQuery );
286 return $this->
getConfig()->get(
'ChangeCredentialsBlacklist' );
A special page subclass for authentication-related special pages.
string $authAction
one of the AuthManager::ACTION_* constants.
performAuthenticationStep( $action, array $requests)
displayForm( $status)
Display the form.
AuthenticationRequest[] $authRequests
string $subPage
Subpage of the special page.
static mergeDefaultFormDescriptor(array $fieldInfo, array $formDescriptor, array $defaultFormDescriptor)
Apply defaults to a form descriptor, without creating non-existend fields.
getRequest()
Get the WebRequest being used for this instance.
trySubmit()
Attempts to do an authentication step with the submitted data.
Special change to change credentials (such as the password).
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
showSubpageList( $error=null)
getAuthForm(array $requests, $action)
doesWrites()
Indicates whether this special page may perform database writes.
handleFormSubmit( $data)
Submit handler callback for HTMLForm.
getPreservedParams( $withToken=false)
Returns URL query parameters which can be used to reload the page (or leave and return) while preserv...
isListed()
Whether this special page is listed in Special:SpecialPages.
getRequestBlacklist()
Allows blacklisting certain request types.
getAuthFormDescriptor( $requests, $action)
Generates a HTMLForm descriptor array from a set of authentication requests.
loadAuth( $subPage, $authAction=null, $reset=false)
Load or initialize $authAction, $authRequests and $subPage.
getDefaultAction( $subPage)
Get the default action for this special page, if none is given via URL/POST data.
__construct(AuthManager $authManager)
needsSubmitButton(array $requests)
Returns true if the form built from the given AuthenticationRequests needs a submit button.
static $loadUserData
Change action needs user data; remove action does not.
execute( $subPage)
Default execute method Checks user permissions.
onAuthChangeFormFields(array $requests, array $fieldInfo, array &$formDescriptor, $action)
Change the form descriptor that determines how a field will look in the authentication form....
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getOutput()
Get the OutputPage being used for this instance.
getUser()
Shortcut to get the User executing this instance.
AuthManager null $authManager
LinkRenderer null $linkRenderer
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getConfig()
Shortcut to get main config object.
setAuthManager(AuthManager $authManager)
Set the injected AuthManager from the special page constructor.
getPageTitle( $subpage=false)
Get a self-referential title object.