3 namespace MediaWiki\Specials;
35 parent::__construct(
'ChangeCredentials',
'editmyprivateinfo' );
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 ) {
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 );
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 ) {
162 $descriptor = parent::getAuthFormDescriptor( $requests, $action );
165 foreach ( $descriptor as &$field ) {
166 if ( $field[
'type'] ===
'password' && $field[
'name'] !==
'retype' ) {
168 if ( isset( $field[
'cssclass'] ) ) {
169 $field[
'cssclass'] .=
' mw-changecredentials-validate-password';
171 $field[
'cssclass'] =
'mw-changecredentials-validate-password';
177 $this->
getOutput()->addModules(
'mediawiki.misc-authed-ooui' );
185 $form = parent::getAuthForm( $requests, $action );
186 $req = reset( $requests );
187 $info = $req->describeCredentials();
191 .
Html::element(
'dt', [], $this->
msg(
'credentialsform-provider' )->text() )
193 .
Html::element(
'dt', [], $this->
msg(
'credentialsform-account' )->text() )
199 $form->setSubmitTextMsg( static::$messagePrefix .
'-submit' );
201 $form->setSubmitID(
'change_credentials_submit' );
214 if ( static::$loadUserData ) {
231 $out->addHTML( $error->parse() );
234 $groupedRequests = [];
235 foreach ( $this->authRequests as $req ) {
236 $info = $req->describeCredentials();
237 $groupedRequests[$info[
'provider']->text()][] = $req;
242 foreach ( $groupedRequests as $group => $members ) {
244 foreach ( $members as $req ) {
246 $info = $req->describeCredentials();
248 $linkRenderer->makeLink(
249 $this->getPageTitle( $req->getUniqueId() ),
250 $info[
'account']->text()
266 $session->setUser( $user );
270 $out->redirect( $returnUrl );
275 $out->msg( static::$messagePrefix .
'-success' )->parse()
278 $out->returnToMain();
287 $returnTo = $request->getText(
'returnto' );
288 $returnToQuery = $request->getText(
'returntoquery',
'' );
295 return $title->getFullUrlForRedirect( $returnToQuery );
306 class_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 Per default the message key is the canonical name o...
The Message class deals with fetching and processing of interface message into a variety of formats.
static newFatal( $message,... $parameters)
Factory function for fatal errors.
static newGood( $value=null)
Factory function for good results.