29 parent::__construct( $main, $action );
33 private $hasAnyRoutes =
null;
39 private function hasAnyRoutes() {
40 if ( $this->hasAnyRoutes ===
null ) {
42 $this->hasAnyRoutes = !empty( $resetRoutes[
'username'] ) || !empty( $resetRoutes[
'email'] );
44 return $this->hasAnyRoutes;
49 if ( !$this->hasAnyRoutes() ) {
50 return 'apihelp-resetpassword-extended-description-noroutes';
52 return parent::getExtendedDescription();
57 if ( !$this->hasAnyRoutes() ) {
58 $this->
dieWithError(
'apihelp-resetpassword-description-noroutes',
'moduledisabled' );
67 $status = $this->passwordReset->isAllowed( $this->
getUser() );
68 if ( !$status->isOK() ) {
69 $this->
dieStatus( Status::wrap( $status ) );
72 $status = $this->passwordReset->execute(
73 $this->
getUser(), $params[
'user'], $params[
'email']
75 if ( !$status->isOK() ) {
76 $status->value =
null;
77 $this->
dieStatus( Status::wrap( $status ) );
81 $result->addValue( [
'resetpassword' ],
'status',
'success' );
86 return $this->hasAnyRoutes();
91 if ( !$this->hasAnyRoutes() ) {
99 if ( !$this->hasAnyRoutes() ) {
105 ParamValidator::PARAM_TYPE =>
'user',
106 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name' ],
109 ParamValidator::PARAM_TYPE =>
'string',
114 if ( empty( $resetRoutes[
'username'] ) ) {
115 unset( $ret[
'user'] );
117 if ( empty( $resetRoutes[
'email'] ) ) {
118 unset( $ret[
'email'] );
129 if ( !empty( $resetRoutes[
'username'] ) ) {
130 $ret[
'action=resetpassword&user=Example&token=123ABC'] =
'apihelp-resetpassword-example-user';
132 if ( !empty( $resetRoutes[
'email'] ) ) {
133 $ret[
'action=resetpassword&user=user@example.com&token=123ABC'] =
134 'apihelp-resetpassword-example-email';
142 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Manage_authentication_data';
147class_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()