39 parent::__construct(
'ChangeCredentials',
'editmyprivateinfo' );
41 $this->sessionManager = $sessionManager;
62 return AuthManager::ACTION_CHANGE;
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' );
112 foreach ( $this->authRequests as $req ) {
113 if ( $req->getUniqueId() ===
$subPage ) {
117 if ( count( $foundReqs ) > 1 ) {
118 throw new LogicException(
'Multiple AuthenticationRequest objects with same ID!' );
120 $this->authRequests = $foundReqs;
126 array $requests, array $fieldInfo, array &$formDescriptor, $action
128 parent::onAuthChangeFormFields( $requests, $fieldInfo, $formDescriptor, $action );
131 if ( AuthenticationRequest::getRequestByClass( $this->authRequests,
132 PasswordAuthenticationRequest::class )
136 'autocomplete' =>
'new-password',
137 'placeholder-message' =>
'createacct-yourpassword-ph',
138 'help-message' =>
'createacct-useuniquepass',
141 'autocomplete' =>
'new-password',
142 'placeholder-message' =>
'createacct-yourpasswordagain-ph',
147 'baseField' =>
'password',
148 'autocomplete' =>
'username',
151 'cssclass' =>
'mw-htmlform-hidden-field',
152 'label-message' =>
'userlogin-yourname',
153 'placeholder-message' =>
'userlogin-yourname-ph',
161 if ( !static::$loadUserData ) {
165 $descriptor = parent::getAuthFormDescriptor( $requests, $action );
168 foreach ( $descriptor as &$field ) {
169 if ( $field[
'type'] ===
'password' && $field[
'name'] !==
'retype' ) {
171 if ( isset( $field[
'cssclass'] ) ) {
172 $field[
'cssclass'] .=
' mw-changecredentials-validate-password';
174 $field[
'cssclass'] =
'mw-changecredentials-validate-password';
181 $this->
getOutput()->addModules(
'mediawiki.misc-authed-ooui' );
189 $form = parent::getAuthForm( $requests, $action );
190 $req = reset( $requests );
191 $info = $req->describeCredentials();
194 Html::openElement(
'dl' )
195 .
Html::element(
'dt', [], $this->
msg(
'credentialsform-provider' )->text() )
197 .
Html::element(
'dt', [], $this->
msg(
'credentialsform-account' )->text() )
199 . Html::closeElement(
'dl' )
203 $form->setSubmitTextMsg( static::$messagePrefix .
'-submit' );
204 $form->showCancel()->setCancelTarget( $this->
getReturnUrl() ?: Title::newMainPage() );
205 $form->setSubmitID(
'change_credentials_submit' );
220 if ( static::$loadUserData ) {
221 $requests = AuthenticationRequest::loadRequestsFromSubmission( $this->authRequests, $data );
227 return Status::newGood( $response );
237 $out->addHTML( $error->parse() );
240 $groupedRequests = [];
241 foreach ( $this->authRequests as $req ) {
242 $info = $req->describeCredentials();
243 $groupedRequests[$info[
'provider']->text()][] = $req;
247 $out->addHTML( Html::openElement(
'dl' ) );
248 foreach ( $groupedRequests as $group => $members ) {
250 foreach ( $members as $req ) {
252 $info = $req->describeCredentials();
253 $out->addHTML( Html::rawElement(
'dd', [],
254 $linkRenderer->makeLink(
255 $this->getPageTitle( $req->getUniqueId() ),
256 $info[
'account']->text()
261 $out->addHTML( Html::closeElement(
'dl' ) );
271 $this->sessionManager->invalidateSessionsForUser( $user );
272 $session->setUser( $user );
276 $out->redirect( $returnUrl );
279 $out->addModuleStyles(
'mediawiki.codex.messagebox.styles' );
282 $out->msg( static::$messagePrefix .
'-success' )->parse()
285 $out->returnToMain();
294 $returnTo = $request->getText(
'returnto' );
295 $returnToQuery = $request->getText(
'returntoquery',
'' );
301 return Title::newFromText( $returnTo )->getFullUrlForRedirect( $returnToQuery );
311class_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.WebRequest 1.18
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...