45 parent::__construct( $main, $action );
47 $this->passwordReset = $passwordReset;
51 private $hasAnyRoutes =
null;
57 private function hasAnyRoutes() {
58 if ( $this->hasAnyRoutes ===
null ) {
60 $this->hasAnyRoutes = !empty( $resetRoutes[
'username'] ) || !empty( $resetRoutes[
'email'] );
62 return $this->hasAnyRoutes;
67 if ( !$this->hasAnyRoutes() ) {
68 return 'apihelp-resetpassword-extended-description-noroutes';
70 return parent::getExtendedDescription();
75 if ( !$this->hasAnyRoutes() ) {
76 $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(
93 if ( !$status->isOK() ) {
94 $status->value =
null;
95 $this->
dieStatus( Status::wrap( $status ) );
99 $result->addValue( [
'resetpassword' ],
'status',
'success' );
103 return $this->hasAnyRoutes();
107 if ( !$this->hasAnyRoutes() ) {
115 if ( !$this->hasAnyRoutes() ) {
121 ParamValidator::PARAM_TYPE =>
'user',
122 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name' ],
125 ParamValidator::PARAM_TYPE =>
'string',
130 if ( empty( $resetRoutes[
'username'] ) ) {
131 unset( $ret[
'user'] );
133 if ( empty( $resetRoutes[
'email'] ) ) {
134 unset( $ret[
'email'] );
145 if ( !empty( $resetRoutes[
'username'] ) ) {
146 $ret[
'action=resetpassword&user=Example&token=123ABC'] =
'apihelp-resetpassword-example-user';
148 if ( !empty( $resetRoutes[
'email'] ) ) {
149 $ret[
'action=resetpassword&user=user@example.com&token=123ABC'] =
150 'apihelp-resetpassword-example-email';
158 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Manage_authentication_data';
163class_alias( ApiResetPassword::class,
'ApiResetPassword' );
array $params
The job parameters.
This is the main API class, used for both external and internal processing.
A class containing constants representing the names of configuration variables.
const PasswordResetRoutes
Name constant for the PasswordResetRoutes setting, for use with Config::get()