45 parent::__construct( $main, $action );
59 $resetRoutes = $this->
getConfig()->get(
'PasswordResetRoutes' );
60 $this->
hasAnyRoutes = !empty( $resetRoutes[
'username'] ) || !empty( $resetRoutes[
'email'] );
67 return 'apihelp-resetpassword-extended-description-noroutes';
69 return parent::getExtendedDescription();
74 $this->
dieWithError(
'apihelp-resetpassword-description-noroutes',
'moduledisabled' );
85 $status = $this->passwordReset->isAllowed( $this->
getUser() );
86 if ( !$status->isOK() ) {
87 $this->
dieStatus( Status::wrap( $status ) );
90 $status = $this->passwordReset->execute(
91 $this->
getUser(), $params[
'user'], $params[
'email']
93 if ( !$status->isOK() ) {
94 $status->value =
null;
95 $this->
dieStatus( Status::wrap( $status ) );
99 $result->addValue( [
'resetpassword' ],
'status',
'success' );
121 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name' ],
128 $resetRoutes = $this->
getConfig()->get(
'PasswordResetRoutes' );
129 if ( empty( $resetRoutes[
'username'] ) ) {
130 unset( $ret[
'user'] );
132 if ( empty( $resetRoutes[
'email'] ) ) {
133 unset( $ret[
'email'] );
141 $resetRoutes = $this->
getConfig()->get(
'PasswordResetRoutes' );
143 if ( !empty( $resetRoutes[
'username'] ) ) {
144 $ret[
'action=resetpassword&user=Example&token=123ABC'] =
'apihelp-resetpassword-example-user';
146 if ( !empty( $resetRoutes[
'email'] ) ) {
147 $ret[
'action=resetpassword&user=user@example.com&token=123ABC'] =
148 'apihelp-resetpassword-example-email';
155 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Manage_authentication_data';
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.
requireOnlyOneParameter( $params,... $required)
Die if none or more than one of a certain set of parameters is set and not false.
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.
getExamplesMessages()
Returns usage examples for this module.
isWriteMode()
Indicates whether this module requires write mode.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
PasswordReset $passwordReset
__construct(ApiMain $main, $action, PasswordReset $passwordReset)
needsToken()
Returns the token type this module requires in order to execute.
hasAnyRoutes()
Determine whether any reset routes are available.
getHelpUrls()
Return links to more detailed help pages about the module.
Helper class for the password reset functionality shared by the web UI and the API.