31 parent::__construct( $main, $action );
33 $this->passwordReset = $passwordReset;
37 private $hasAnyRoutes =
null;
43 private function hasAnyRoutes() {
44 if ( $this->hasAnyRoutes ===
null ) {
46 $this->hasAnyRoutes = !empty( $resetRoutes[
'username'] ) || !empty( $resetRoutes[
'email'] );
48 return $this->hasAnyRoutes;
53 if ( !$this->hasAnyRoutes() ) {
54 return 'apihelp-resetpassword-extended-description-noroutes';
56 return parent::getExtendedDescription();
61 if ( !$this->hasAnyRoutes() ) {
62 $this->
dieWithError(
'apihelp-resetpassword-description-noroutes',
'moduledisabled' );
71 $status = $this->passwordReset->isAllowed( $this->
getUser() );
72 if ( !$status->isOK() ) {
73 $this->
dieStatus( Status::wrap( $status ) );
76 $status = $this->passwordReset->execute(
77 $this->
getUser(), $params[
'user'], $params[
'email']
79 if ( !$status->isOK() ) {
80 $status->value =
null;
81 $this->
dieStatus( Status::wrap( $status ) );
85 $result->addValue( [
'resetpassword' ],
'status',
'success' );
90 return $this->hasAnyRoutes();
95 if ( !$this->hasAnyRoutes() ) {
103 if ( !$this->hasAnyRoutes() ) {
109 ParamValidator::PARAM_TYPE =>
'user',
110 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name' ],
113 ParamValidator::PARAM_TYPE =>
'string',
118 if ( empty( $resetRoutes[
'username'] ) ) {
119 unset( $ret[
'user'] );
121 if ( empty( $resetRoutes[
'email'] ) ) {
122 unset( $ret[
'email'] );
133 if ( !empty( $resetRoutes[
'username'] ) ) {
134 $ret[
'action=resetpassword&user=Example&token=123ABC'] =
'apihelp-resetpassword-example-user';
136 if ( !empty( $resetRoutes[
'email'] ) ) {
137 $ret[
'action=resetpassword&user=user@example.com&token=123ABC'] =
138 'apihelp-resetpassword-example-email';
146 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Manage_authentication_data';
151class_alias( ApiResetPassword::class,
'ApiResetPassword' );
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()