30 parent::__construct( $mainModule, $moduleName );
31 $this->authManager = $authManager;
32 $this->userFactory = $userFactory;
41 if ( $params[
'user'] !==
null ) {
42 $user = $this->userFactory->newFromName(
44 UserFactory::RIGOR_CREATABLE
50 "baduser_{$encParamName}"
54 if ( $user->isRegistered() || $this->authManager->userExists( $user->getName() ) ) {
58 $user->setEmail( (
string)$params[
'email'] );
59 $user->setRealName( (
string)$params[
'realname'] );
65 $validity = $user->checkPasswordValidity( $params[
'password'] );
66 $r[
'validity'] = $validity->isGood() ?
'Good' : ( $validity->isOK() ?
'Change' :
'Invalid' );
67 $messages = array_merge(
72 $r[
'validitymessages'] = $messages;
92 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'id' ],
101 'action=validatepassword&password=foobar'
102 =>
'apihelp-validatepassword-example-1',
103 'action=validatepassword&password=querty&user=Example'
104 =>
'apihelp-validatepassword-example-2',
109 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.