32 parent::__construct( $mainModule, $moduleName );
33 $this->authManager = $authManager;
34 $this->userFactory = $userFactory;
42 if ( $params[
'user'] !==
null ) {
43 $user = $this->userFactory->newFromName(
45 UserRigorOptions::RIGOR_CREATABLE
51 "baduser_{$encParamName}"
55 if ( $user->isRegistered() || $this->authManager->userExists( $user->getName() ) ) {
59 $user->setEmail( (
string)$params[
'email'] );
60 $user->setRealName( (
string)$params[
'realname'] );
66 $validity = $user->checkPasswordValidity( $params[
'password'] );
67 $r[
'validity'] = $validity->isGood() ?
'Good' : ( $validity->isOK() ?
'Change' :
'Invalid' );
68 $messages = array_merge(
73 $r[
'validitymessages'] = $messages;
88 ParamValidator::PARAM_TYPE =>
'password',
89 ParamValidator::PARAM_REQUIRED =>
true
92 ParamValidator::PARAM_TYPE =>
'user',
93 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'id' ],
102 'action=validatepassword&password=foobar'
103 =>
'apihelp-validatepassword-example-1',
104 'action=validatepassword&password=querty&user=Example'
105 =>
'apihelp-validatepassword-example-2',
110 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Validatepassword';
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
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.
encodeParamName( $paramName)
This method mangles parameter name based on the prefix supplied to the constructor.
requirePostedParameters( $params, $prefix='prefix')
Die if any of the specified parameters were found in the query part of the URL rather than the post b...
getResult()
Get the result object.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
getModuleName()
Get the name of the module being executed by this instance.
getHookRunner()
Get an ApiHookRunner for running core API hooks.
This is the main API class, used for both external and internal processing.
getExamplesMessages()
Returns usage examples for this module.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
mustBePosted()
Indicates whether this module must be called with a POST request.
__construct(ApiMain $mainModule, string $moduleName, AuthManager $authManager, UserFactory $userFactory)
getHelpUrls()
Return links to more detailed help pages about the module.