38 parent::__construct(
'ChangeCredentials',
'editmyprivateinfo' );
56 return AuthManager::ACTION_CHANGE;
70 if ( !$this->authRequests ) {
77 $out->addModules(
'mediawiki.special.changecredentials' );
81 if ( $status ===
false || !$status->isOK() ) {
86 $response = $status->getValue();
88 switch ( $response->status ) {
89 case AuthenticationResponse::PASS:
92 case AuthenticationResponse::FAIL:
93 $this->
displayForm( Status::newFatal( $response->message ) );
96 throw new LogicException(
'invalid AuthenticationResponse' );
104 foreach ( $this->authRequests as $req ) {
105 if ( $req->getUniqueId() ===
$subPage ) {
109 if ( count( $foundReqs ) > 1 ) {
110 throw new LogicException(
'Multiple AuthenticationRequest objects with same ID!' );
112 $this->authRequests = $foundReqs;
118 array $requests, array $fieldInfo, array &$formDescriptor, $action
120 parent::onAuthChangeFormFields( $requests, $fieldInfo, $formDescriptor, $action );
123 if ( AuthenticationRequest::getRequestByClass( $this->authRequests,
124 PasswordAuthenticationRequest::class )
128 'autocomplete' =>
'new-password',
129 'placeholder-message' =>
'createacct-yourpassword-ph',
130 'help-message' =>
'createacct-useuniquepass',
133 'autocomplete' =>
'new-password',
134 'placeholder-message' =>
'createacct-yourpasswordagain-ph',
139 'baseField' =>
'password',
140 'autocomplete' =>
'username',
143 'cssclass' =>
'mw-htmlform-hidden-field',
144 'label-message' =>
'userlogin-yourname',
145 'placeholder-message' =>
'userlogin-yourname-ph',
152 if ( !static::$loadUserData ) {
156 $descriptor = parent::getAuthFormDescriptor( $requests, $action );
159 foreach ( $descriptor as &$field ) {
160 if ( $field[
'type'] ===
'password' && $field[
'name'] !==
'retype' ) {
162 if ( isset( $field[
'cssclass'] ) ) {
163 $field[
'cssclass'] .=
' mw-changecredentials-validate-password';
165 $field[
'cssclass'] =
'mw-changecredentials-validate-password';
172 $this->
getOutput()->addModules(
'mediawiki.misc-authed-ooui' );
179 $form = parent::getAuthForm( $requests, $action );
180 $req = reset( $requests );
181 $info = $req->describeCredentials();
184 Html::openElement(
'dl' )
185 .
Html::element(
'dt', [], $this->
msg(
'credentialsform-provider' )->text() )
187 .
Html::element(
'dt', [], $this->
msg(
'credentialsform-account' )->text() )
189 . Html::closeElement(
'dl' )
193 $form->setSubmitTextMsg( static::$messagePrefix .
'-submit' );
194 $form->showCancel()->setCancelTarget( $this->
getReturnUrl() ?: Title::newMainPage() );
195 $form->setSubmitID(
'change_credentials_submit' );
208 if ( static::$loadUserData ) {
209 $requests = AuthenticationRequest::loadRequestsFromSubmission( $this->authRequests, $data );
215 return Status::newGood( $response );
225 $out->addHTML( $error->parse() );
228 $groupedRequests = [];
229 foreach ( $this->authRequests as $req ) {
230 $info = $req->describeCredentials();
231 $groupedRequests[$info[
'provider']->text()][] = $req;
235 $out->addHTML( Html::openElement(
'dl' ) );
236 foreach ( $groupedRequests as $group => $members ) {
238 foreach ( $members as $req ) {
240 $info = $req->describeCredentials();
241 $out->addHTML( Html::rawElement(
'dd', [],
242 $linkRenderer->makeLink(
243 $this->getPageTitle( $req->getUniqueId() ),
244 $info[
'account']->text()
249 $out->addHTML( Html::closeElement(
'dl' ) );
259 SessionManager::singleton()->invalidateSessionsForUser( $user );
260 $session->setUser( $user );
264 $out->redirect( $returnUrl );
269 $out->msg( static::$messagePrefix .
'-success' )->parse()
272 $out->returnToMain();
281 $returnTo = $request->getText(
'returnto' );
282 $returnToQuery = $request->getText(
'returntoquery',
'' );
288 return Title::newFromText( $returnTo )->getFullUrlForRedirect( $returnToQuery );
297class_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...