41 parent::__construct(
'ChangeCredentials',
'editmyprivateinfo' );
59 return AuthManager::ACTION_CHANGE;
73 if ( !$this->authRequests ) {
80 $out->addModules(
'mediawiki.special.changecredentials' );
84 if ( $status ===
false || !$status->isOK() ) {
89 $response = $status->getValue();
91 switch ( $response->status ) {
92 case AuthenticationResponse::PASS:
95 case AuthenticationResponse::FAIL:
96 $this->
displayForm( Status::newFatal( $response->message ) );
99 throw new LogicException(
'invalid AuthenticationResponse' );
107 foreach ( $this->authRequests as $req ) {
108 if ( $req->getUniqueId() ===
$subPage ) {
112 if ( count( $foundReqs ) > 1 ) {
113 throw new LogicException(
'Multiple AuthenticationRequest objects with same ID!' );
115 $this->authRequests = $foundReqs;
121 array $requests, array $fieldInfo, array &$formDescriptor, $action
123 parent::onAuthChangeFormFields( $requests, $fieldInfo, $formDescriptor, $action );
126 if ( AuthenticationRequest::getRequestByClass( $this->authRequests,
127 PasswordAuthenticationRequest::class )
131 'autocomplete' =>
'new-password',
132 'placeholder-message' =>
'createacct-yourpassword-ph',
133 'help-message' =>
'createacct-useuniquepass',
136 'autocomplete' =>
'new-password',
137 'placeholder-message' =>
'createacct-yourpasswordagain-ph',
142 'baseField' =>
'password',
143 'autocomplete' =>
'username',
146 'cssclass' =>
'mw-htmlform-hidden-field',
147 'label-message' =>
'userlogin-yourname',
148 'placeholder-message' =>
'userlogin-yourname-ph',
155 if ( !static::$loadUserData ) {
159 $descriptor = parent::getAuthFormDescriptor( $requests, $action );
162 foreach ( $descriptor as &$field ) {
163 if ( $field[
'type'] ===
'password' && $field[
'name'] !==
'retype' ) {
165 if ( isset( $field[
'cssclass'] ) ) {
166 $field[
'cssclass'] .=
' mw-changecredentials-validate-password';
168 $field[
'cssclass'] =
'mw-changecredentials-validate-password';
175 $this->
getOutput()->addModules(
'mediawiki.misc-authed-ooui' );
182 $form = parent::getAuthForm( $requests, $action );
183 $req = reset( $requests );
184 $info = $req->describeCredentials();
187 Html::openElement(
'dl' )
188 .
Html::element(
'dt', [], $this->
msg(
'credentialsform-provider' )->text() )
190 .
Html::element(
'dt', [], $this->
msg(
'credentialsform-account' )->text() )
192 . Html::closeElement(
'dl' )
196 $form->setSubmitTextMsg( static::$messagePrefix .
'-submit' );
197 $form->showCancel()->setCancelTarget( $this->
getReturnUrl() ?: Title::newMainPage() );
198 $form->setSubmitID(
'change_credentials_submit' );
211 if ( static::$loadUserData ) {
212 $requests = AuthenticationRequest::loadRequestsFromSubmission( $this->authRequests, $data );
218 return Status::newGood( $response );
228 $out->addHTML( $error->parse() );
231 $groupedRequests = [];
232 foreach ( $this->authRequests as $req ) {
233 $info = $req->describeCredentials();
234 $groupedRequests[$info[
'provider']->text()][] = $req;
238 $out->addHTML( Html::openElement(
'dl' ) );
239 foreach ( $groupedRequests as $group => $members ) {
241 foreach ( $members as $req ) {
243 $info = $req->describeCredentials();
244 $out->addHTML( Html::rawElement(
'dd', [],
245 $linkRenderer->makeLink(
246 $this->getPageTitle( $req->getUniqueId() ),
247 $info[
'account']->text()
252 $out->addHTML( Html::closeElement(
'dl' ) );
262 SessionManager::singleton()->invalidateSessionsForUser( $user );
263 $session->setUser( $user );
267 $out->redirect( $returnUrl );
272 $out->msg( static::$messagePrefix .
'-success' )->parse()
275 $out->returnToMain();
284 $returnTo = $request->getText(
'returnto' );
285 $returnToQuery = $request->getText(
'returntoquery',
'' );
291 return Title::newFromText( $returnTo )->getFullUrlForRedirect( $returnToQuery );
300class_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...