39 parent::__construct(
'ChangeCredentials',
'editmyprivateinfo' );
57 return AuthManager::ACTION_CHANGE;
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 ) {
157 $descriptor = parent::getAuthFormDescriptor( $requests, $action );
160 foreach ( $descriptor as &$field ) {
161 if ( $field[
'type'] ===
'password' && $field[
'name'] !==
'retype' ) {
163 if ( isset( $field[
'cssclass'] ) ) {
164 $field[
'cssclass'] .=
' mw-changecredentials-validate-password';
166 $field[
'cssclass'] =
'mw-changecredentials-validate-password';
173 $this->
getOutput()->addModules(
'mediawiki.misc-authed-ooui' );
180 $form = parent::getAuthForm( $requests, $action );
181 $req = reset( $requests );
182 $info = $req->describeCredentials();
185 Html::openElement(
'dl' )
186 .
Html::element(
'dt', [], $this->
msg(
'credentialsform-provider' )->text() )
188 .
Html::element(
'dt', [], $this->
msg(
'credentialsform-account' )->text() )
190 . Html::closeElement(
'dl' )
194 $form->setSubmitTextMsg( static::$messagePrefix .
'-submit' );
195 $form->showCancel()->setCancelTarget( $this->
getReturnUrl() ?: Title::newMainPage() );
196 $form->setSubmitID(
'change_credentials_submit' );
209 if ( static::$loadUserData ) {
210 $requests = AuthenticationRequest::loadRequestsFromSubmission( $this->authRequests, $data );
216 return Status::newGood( $response );
226 $out->addHTML( $error->parse() );
229 $groupedRequests = [];
230 foreach ( $this->authRequests as $req ) {
231 $info = $req->describeCredentials();
232 $groupedRequests[$info[
'provider']->text()][] = $req;
236 $out->addHTML( Html::openElement(
'dl' ) );
237 foreach ( $groupedRequests as $group => $members ) {
239 foreach ( $members as $req ) {
241 $info = $req->describeCredentials();
242 $out->addHTML( Html::rawElement(
'dd', [],
243 $linkRenderer->makeLink(
244 $this->getPageTitle( $req->getUniqueId() ),
245 $info[
'account']->text()
250 $out->addHTML( Html::closeElement(
'dl' ) );
260 SessionManager::singleton()->invalidateSessionsForUser( $user );
261 $session->setUser( $user );
265 $out->redirect( $returnUrl );
270 $out->msg( static::$messagePrefix .
'-success' )->parse()
273 $out->returnToMain();
282 $returnTo = $request->getText(
'returnto' );
283 $returnToQuery = $request->getText(
'returntoquery',
'' );
289 return Title::newFromText( $returnTo )->getFullUrlForRedirect( $returnToQuery );
298class_alias( SpecialChangeCredentials::class,
'SpecialChangeCredentials' );
A class containing constants representing the names of configuration variables.
const ChangeCredentialsBlacklist
Name constant for the ChangeCredentialsBlacklist setting, for use with Config::get()
A special page subclass for authentication-related special pages.
AuthenticationRequest[] $authRequests
string $subPage
Subpage of the special page.
performAuthenticationStep( $action, array $requests)
displayForm( $status)
Display the form.
string $authAction
one of the AuthManager::ACTION_* constants.
static mergeDefaultFormDescriptor(array $fieldInfo, array $formDescriptor, array $defaultFormDescriptor)
Apply defaults to a form descriptor, without creating non-existent fields.
trySubmit()
Attempts to do an authentication step with the submitted data.
getRequest()
Get the WebRequest being used for this instance.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getUser()
Shortcut to get the User executing this instance.
setAuthManager(AuthManager $authManager)
Set the injected AuthManager from the special page constructor.
getPageTitle( $subpage=false)
Get a self-referential title object.
getConfig()
Shortcut to get main config object.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getOutput()
Get the OutputPage being used for this instance.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages By default the message key is the canonical name of...