MediaWiki master
MediaWiki\User\PasswordReset Class Reference

Helper class for the password reset functionality shared by the web UI and the API. More...

Inherits LoggerAwareInterface.

Collaboration diagram for MediaWiki\User\PasswordReset:

Public Member Functions

 __construct (ServiceOptions $config, LoggerInterface $logger, AuthManager $authManager, HookContainer $hookContainer, IConnectionProvider $dbProvider, UserFactory $userFactory, UserNameUtils $userNameUtils, UserOptionsLookup $userOptionsLookup)
 This class is managed by MediaWikiServices, don't instantiate directly.
 
 execute (User $performingUser, $username=null, $email=null)
 Do a password reset.
 
 isAllowed (User $user)
 Check if a given user has permission to use this functionality.
 
 isEnabled ()
 

Public Attributes

const CONSTRUCTOR_OPTIONS
 

Protected Member Functions

 getUsersByEmail ( $email)
 

Detailed Description

Helper class for the password reset functionality shared by the web UI and the API.

Requires the TemporaryPasswordPrimaryAuthenticationProvider and the EmailNotificationSecondaryAuthenticationProvider (or something providing equivalent functionality) to be enabled.

Definition at line 51 of file PasswordReset.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\User\PasswordReset::__construct ( ServiceOptions $config,
LoggerInterface $logger,
AuthManager $authManager,
HookContainer $hookContainer,
IConnectionProvider $dbProvider,
UserFactory $userFactory,
UserNameUtils $userNameUtils,
UserOptionsLookup $userOptionsLookup )

This class is managed by MediaWikiServices, don't instantiate directly.

Parameters
ServiceOptions$config
LoggerInterface$logger
AuthManager$authManager
HookContainer$hookContainer
IConnectionProvider$dbProvider
UserFactory$userFactory
UserNameUtils$userNameUtils
UserOptionsLookup$userOptionsLookup

Definition at line 90 of file PasswordReset.php.

References MediaWiki\Config\ServiceOptions\assertRequiredOptions().

Member Function Documentation

◆ execute()

MediaWiki\User\PasswordReset::execute ( User $performingUser,
$username = null,
$email = null )

Do a password reset.

Authorization is the caller's responsibility.

Process the form. At this point we know that the user passes all the criteria in userCanExecute(), and if the data array contains 'Username', etc, then Username resets are allowed.

Since
1.29 Fourth argument for displayPassword removed.
Parameters
User$performingUserThe user that does the password reset
string | null$usernameThe user whose password is reset
string | null$emailAlternative way to specify the user
Returns
StatusValue

Definition at line 190 of file PasswordReset.php.

References MediaWiki\User\User\getId(), MediaWiki\User\User\getName(), MediaWiki\User\User\getRequest(), and MediaWiki\User\User\pingLimiter().

◆ getUsersByEmail()

MediaWiki\User\PasswordReset::getUsersByEmail ( $email)
protected
Note
This is protected to allow configuring in tests. This class is not stable to extend.
Parameters
string$email
Returns
User[]

Definition at line 373 of file PasswordReset.php.

◆ isAllowed()

MediaWiki\User\PasswordReset::isAllowed ( User $user)

Check if a given user has permission to use this functionality.

Parameters
User$user
Since
1.29 Second argument for displayPassword removed.
Returns
StatusValue

Definition at line 121 of file PasswordReset.php.

References MediaWiki\User\User\getName().

◆ isEnabled()

MediaWiki\User\PasswordReset::isEnabled ( )
Since
1.42
Returns
StatusValue

Definition at line 134 of file PasswordReset.php.

Member Data Documentation

◆ CONSTRUCTOR_OPTIONS

const MediaWiki\User\PasswordReset::CONSTRUCTOR_OPTIONS
Initial value:
= [
]
const EnableEmail
Name constant for the EnableEmail setting, for use with Config::get()
const PasswordResetRoutes
Name constant for the PasswordResetRoutes setting, for use with Config::get()
const AllowRequiringEmailForResets
Name constant for the AllowRequiringEmailForResets setting, for use with Config::get()
Access: internal
For use by ServiceWiring

Definition at line 72 of file PasswordReset.php.


The documentation for this class was generated from the following file: