35 parent::__construct(
'ChangeCredentials',
'editmyprivateinfo' );
53 return AuthManager::ACTION_CHANGE;
58 $params = parent::getPreservedParams( $withToken );
60 'returnto' => $request->getVal(
'returnto' ),
61 'returntoquery' => $request->getVal(
'returntoquery' ),
77 if ( !$this->authRequests ) {
84 $out->addModules(
'mediawiki.special.changecredentials' );
88 if ( $status ===
false || !$status->isOK() ) {
93 $response = $status->getValue();
95 switch ( $response->status ) {
96 case AuthenticationResponse::PASS:
99 case AuthenticationResponse::FAIL:
100 $this->
displayForm( Status::newFatal( $response->message ) );
103 throw new LogicException(
'invalid AuthenticationResponse' );
111 foreach ( $this->authRequests as $req ) {
112 if ( $req->getUniqueId() ===
$subPage ) {
116 if ( count( $foundReqs ) > 1 ) {
117 throw new LogicException(
'Multiple AuthenticationRequest objects with same ID!' );
119 $this->authRequests = $foundReqs;
125 array $requests, array $fieldInfo, array &$formDescriptor, $action
127 parent::onAuthChangeFormFields( $requests, $fieldInfo, $formDescriptor, $action );
130 if ( AuthenticationRequest::getRequestByClass( $this->authRequests,
131 PasswordAuthenticationRequest::class )
135 'autocomplete' =>
'new-password',
136 'placeholder-message' =>
'createacct-yourpassword-ph',
137 'help-message' =>
'createacct-useuniquepass',
140 'autocomplete' =>
'new-password',
141 'placeholder-message' =>
'createacct-yourpasswordagain-ph',
146 'baseField' =>
'password',
147 'autocomplete' =>
'username',
150 'cssclass' =>
'mw-htmlform-hidden-field',
151 'label-message' =>
'userlogin-yourname',
152 'placeholder-message' =>
'userlogin-yourname-ph',
159 if ( !static::$loadUserData ) {
163 $descriptor = parent::getAuthFormDescriptor( $requests, $action );
166 foreach ( $descriptor as &$field ) {
167 if ( $field[
'type'] ===
'password' && $field[
'name'] !==
'retype' ) {
169 if ( isset( $field[
'cssclass'] ) ) {
170 $field[
'cssclass'] .=
' mw-changecredentials-validate-password';
172 $field[
'cssclass'] =
'mw-changecredentials-validate-password';
179 $this->
getOutput()->addModules(
'mediawiki.misc-authed-ooui' );
186 $form = parent::getAuthForm( $requests, $action );
187 $req = reset( $requests );
188 $info = $req->describeCredentials();
191 Html::openElement(
'dl' )
192 .
Html::element(
'dt', [], $this->
msg(
'credentialsform-provider' )->text() )
194 .
Html::element(
'dt', [], $this->
msg(
'credentialsform-account' )->text() )
196 . Html::closeElement(
'dl' )
200 $form->setSubmitTextMsg( static::$messagePrefix .
'-submit' );
201 $form->showCancel()->setCancelTarget( $this->
getReturnUrl() ?: Title::newMainPage() );
202 $form->setSubmitID(
'change_credentials_submit' );
215 if ( static::$loadUserData ) {
216 $requests = AuthenticationRequest::loadRequestsFromSubmission( $this->authRequests, $data );
222 return Status::newGood( $response );
232 $out->addHTML( $error->parse() );
235 $groupedRequests = [];
236 foreach ( $this->authRequests as $req ) {
237 $info = $req->describeCredentials();
238 $groupedRequests[$info[
'provider']->text()][] = $req;
242 $out->addHTML( Html::openElement(
'dl' ) );
243 foreach ( $groupedRequests as $group => $members ) {
245 foreach ( $members as $req ) {
247 $info = $req->describeCredentials();
248 $out->addHTML( Html::rawElement(
'dd', [],
249 $linkRenderer->makeLink(
250 $this->getPageTitle( $req->getUniqueId() ),
251 $info[
'account']->text()
256 $out->addHTML( Html::closeElement(
'dl' ) );
266 SessionManager::singleton()->invalidateSessionsForUser( $user );
267 $session->setUser( $user );
271 $out->redirect( $returnUrl );
276 $out->msg( static::$messagePrefix .
'-success' )->parse()
279 $out->returnToMain();
288 $returnTo = $request->getText(
'returnto' );
289 $returnToQuery = $request->getText(
'returntoquery',
'' );
295 return Title::newFromText( $returnTo )->getFullUrlForRedirect( $returnToQuery );
304class_alias( SpecialChangeCredentials::class,
'SpecialChangeCredentials' );
array $params
The job parameters.
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...