48 parent::__construct( $main, $action );
50 $this->passwordReset = $passwordReset;
54 private $hasAnyRoutes =
null;
60 private function hasAnyRoutes() {
61 if ( $this->hasAnyRoutes ===
null ) {
62 $resetRoutes = $this->
getConfig()->get( MainConfigNames::PasswordResetRoutes );
63 $this->hasAnyRoutes = !empty( $resetRoutes[
'username'] ) || !empty( $resetRoutes[
'email'] );
65 return $this->hasAnyRoutes;
70 if ( !$this->hasAnyRoutes() ) {
71 return 'apihelp-resetpassword-extended-description-noroutes';
73 return parent::getExtendedDescription();
78 if ( !$this->hasAnyRoutes() ) {
79 $this->
dieWithError(
'apihelp-resetpassword-description-noroutes',
'moduledisabled' );
88 $status = $this->passwordReset->isAllowed( $this->
getUser() );
89 if ( !$status->isOK() ) {
90 $this->
dieStatus( Status::wrap( $status ) );
93 $status = $this->passwordReset->execute(
96 if ( !$status->isOK() ) {
97 $status->value =
null;
98 $this->
dieStatus( Status::wrap( $status ) );
102 $result->addValue( [
'resetpassword' ],
'status',
'success' );
106 return $this->hasAnyRoutes();
110 if ( !$this->hasAnyRoutes() ) {
118 if ( !$this->hasAnyRoutes() ) {
124 ParamValidator::PARAM_TYPE =>
'user',
125 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name' ],
128 ParamValidator::PARAM_TYPE =>
'string',
132 $resetRoutes = $this->
getConfig()->get( MainConfigNames::PasswordResetRoutes );
133 if ( empty( $resetRoutes[
'username'] ) ) {
134 unset( $ret[
'user'] );
136 if ( empty( $resetRoutes[
'email'] ) ) {
137 unset( $ret[
'email'] );
146 $resetRoutes = $this->
getConfig()->get( MainConfigNames::PasswordResetRoutes );
148 if ( !empty( $resetRoutes[
'username'] ) ) {
149 $ret[
'action=resetpassword&user=Example&token=123ABC'] =
'apihelp-resetpassword-example-user';
151 if ( !empty( $resetRoutes[
'email'] ) ) {
152 $ret[
'action=resetpassword&user=user@example.com&token=123ABC'] =
153 'apihelp-resetpassword-example-email';
161 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Manage_authentication_data';
array $params
The job parameters.
This abstract class implements many basic API functions, and is the base of all API classes.
dieWithError( $msg, $code=null, $data=null, $httpCode=0)
Abort execution with an error.
getResult()
Get the result object.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
dieStatus(StatusValue $status)
Throw an ApiUsageException based on the Status object.
This is the main API class, used for both external and internal processing.
Reset password, with AuthManager.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
getExtendedDescription()
Return the extended help text message.This is additional text to display at the top of the help secti...
getExamplesMessages()
Returns usage examples for this module.Return value has query strings as keys, with values being eith...
isWriteMode()
Indicates whether this module requires write mode.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.Concrete implementatio...
__construct(ApiMain $main, $action, PasswordReset $passwordReset)
needsToken()
Returns the token type this module requires in order to execute.
getHelpUrls()
Return links to more detailed help pages about the module.1.25, returning boolean false is deprecated...
A class containing constants representing the names of configuration variables.