29 parent::__construct(
'ChangeCredentials',
'editmyprivateinfo' );
47 return AuthManager::ACTION_CHANGE;
52 $params = parent::getPreservedParams( $withToken );
54 'returnto' => $request->getVal(
'returnto' ),
55 'returntoquery' => $request->getVal(
'returntoquery' ),
71 if ( !$this->authRequests ) {
78 $out->addModules(
'mediawiki.special.changecredentials' );
82 if ( $status ===
false || !$status->isOK() ) {
87 $response = $status->getValue();
89 switch ( $response->status ) {
90 case AuthenticationResponse::PASS:
93 case AuthenticationResponse::FAIL:
94 $this->
displayForm( Status::newFatal( $response->message ) );
97 throw new LogicException(
'invalid AuthenticationResponse' );
105 foreach ( $this->authRequests as $req ) {
106 if ( $req->getUniqueId() ===
$subPage ) {
110 if ( count( $foundReqs ) > 1 ) {
111 throw new LogicException(
'Multiple AuthenticationRequest objects with same ID!' );
113 $this->authRequests = $foundReqs;
119 array $requests, array $fieldInfo, array &$formDescriptor, $action
121 parent::onAuthChangeFormFields( $requests, $fieldInfo, $formDescriptor, $action );
124 if ( AuthenticationRequest::getRequestByClass( $this->authRequests,
125 PasswordAuthenticationRequest::class )
129 'autocomplete' =>
'new-password',
130 'placeholder-message' =>
'createacct-yourpassword-ph',
131 'help-message' =>
'createacct-useuniquepass',
134 'autocomplete' =>
'new-password',
135 'placeholder-message' =>
'createacct-yourpasswordagain-ph',
140 'baseField' =>
'password',
141 'autocomplete' =>
'username',
144 'cssclass' =>
'mw-htmlform-hidden-field',
145 'label-message' =>
'userlogin-yourname',
146 'placeholder-message' =>
'userlogin-yourname-ph',
153 if ( !static::$loadUserData ) {
156 $descriptor = parent::getAuthFormDescriptor( $requests, $action );
159 foreach ( $descriptor as &$field ) {
160 if ( $field[
'type'] ===
'password' && $field[
'name'] !==
'retype' ) {
162 if ( isset( $field[
'cssclass'] ) ) {
163 $field[
'cssclass'] .=
' mw-changecredentials-validate-password';
165 $field[
'cssclass'] =
'mw-changecredentials-validate-password';
171 $this->
getOutput()->addModules(
'mediawiki.misc-authed-ooui' );
179 $form = parent::getAuthForm( $requests, $action );
180 $req = reset( $requests );
181 $info = $req->describeCredentials();
184 Html::openElement(
'dl' )
185 . Html::element(
'dt', [], $this->
msg(
'credentialsform-provider' )->text() )
186 . Html::element(
'dd', [], $info[
'provider']->text() )
187 . Html::element(
'dt', [], $this->
msg(
'credentialsform-account' )->text() )
188 . Html::element(
'dd', [], $info[
'account']->text() )
189 . Html::closeElement(
'dl' )
193 $form->setSubmitTextMsg( static::$messagePrefix .
'-submit' );
194 $form->showCancel()->setCancelTarget( $this->
getReturnUrl() ?: Title::newMainPage() );
195 $form->setSubmitID(
'change_credentials_submit' );
208 if ( static::$loadUserData ) {
209 $requests = AuthenticationRequest::loadRequestsFromSubmission( $this->authRequests, $data );
215 return Status::newGood( $response );
225 $out->addHTML( $error->parse() );
228 $groupedRequests = [];
229 foreach ( $this->authRequests as $req ) {
230 $info = $req->describeCredentials();
231 $groupedRequests[$info[
'provider']->text()][] = $req;
235 $out->addHTML( Html::openElement(
'dl' ) );
236 foreach ( $groupedRequests as $group => $members ) {
237 $out->addHTML( Html::element(
'dt', [], $group ) );
238 foreach ( $members as $req ) {
240 $info = $req->describeCredentials();
241 $out->addHTML( Html::rawElement(
'dd', [],
242 $linkRenderer->makeLink(
243 $this->getPageTitle( $req->getUniqueId() ),
244 $info[
'account']->text()
249 $out->addHTML( Html::closeElement(
'dl' ) );
259 SessionManager::singleton()->invalidateSessionsForUser( $user );
260 $session->setUser( $user );
264 $out->redirect( $returnUrl );
269 $out->msg( static::$messagePrefix .
'-success' )->parse()
272 $out->returnToMain();
281 $returnTo = $request->getText(
'returnto' );
282 $returnToQuery = $request->getText(
'returntoquery',
'' );
288 $title = Title::newFromText( $returnTo );
289 return $title->getFullUrlForRedirect( $returnToQuery );
293 return $this->
getConfig()->get( MainConfigNames::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-existent fields.
getRequest()
Get the WebRequest being used for this instance.
trySubmit()
Attempts to do an authentication step with the submitted data.
A class containing constants representing the names of configuration variables.
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.
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.