51 parent::__construct(
'PasswordReset',
'editmyprivateinfo' );
59 return $this->
canChangePassword( $user ) ===
true && parent::userCanExecute( $user );
64 if ( is_string( $error ) ) {
66 } elseif ( !$error ) {
67 throw new ErrorPageError(
'internalerror',
'resetpass_forbidden' );
70 parent::checkExecutePermissions( $user );
75 $resetRoutes = $this->
getConfig()->get(
'PasswordResetRoutes' );
77 if ( isset( $resetRoutes[
'username'] ) && $resetRoutes[
'username'] ) {
80 'label-message' =>
'passwordreset-username',
83 if ( $this->
getUser()->isLoggedIn() ) {
84 $a[
'Username'][
'default'] = $this->
getUser()->getName();
88 if ( isset( $resetRoutes[
'email'] ) && $resetRoutes[
'email'] ) {
91 'label-message' =>
'passwordreset-email',
95 if ( isset( $resetRoutes[
'domain'] ) && $resetRoutes[
'domain'] ) {
96 $domains = $wgAuth->domainList();
99 'options' => $domains,
100 'label-message' =>
'passwordreset-domain',
104 if ( $this->
getUser()->isAllowed(
'passwordreset' ) ) {
107 'label-message' =>
'passwordreset-capture',
108 'help-message' =>
'passwordreset-capture-help',
120 $resetRoutes = $this->
getConfig()->get(
'PasswordResetRoutes' );
125 if ( isset( $resetRoutes[
'username'] ) && $resetRoutes[
'username'] ) {
128 if ( isset( $resetRoutes[
'email'] ) && $resetRoutes[
'email'] ) {
131 if ( isset( $resetRoutes[
'domain'] ) && $resetRoutes[
'domain'] ) {
135 $message = ( $i > 1 ) ?
'passwordreset-text-many' :
'passwordreset-text-one';
153 if ( isset( $data[
'Domain'] ) ) {
154 if ( $wgAuth->validDomain( $data[
'Domain'] ) ) {
155 $wgAuth->setDomain( $data[
'Domain'] );
157 $wgAuth->setDomain(
'invaliddomain' );
161 if ( isset( $data[
'Capture'] ) && !$this->
getUser()->isAllowed(
'passwordreset' ) ) {
172 if ( isset( $data[
'Username'] ) && $data[
'Username'] !==
'' ) {
175 } elseif ( isset( $data[
'Email'] )
176 && $data[
'Email'] !==
''
183 [
'user_email' => $data[
'Email'] ],
190 foreach (
$res as $row ) {
195 throw new MWException(
'Unknown database error in ' . __METHOD__ );
204 if ( !
Hooks::run(
'SpecialPasswordResetOnSubmit', [ &$users, $data, &$error ] ) ) {
210 if ( count( $users ) == 0 ) {
227 if ( $this->
getUser()->pingLimiter(
'mailpassword' ) ) {
233 if ( $user->isPasswordReminderThrottled() ) {
235 # Round the time in hours to 3 d.p., in case someone is specifying
236 # minutes or seconds.
238 'throttled-mailpassword',
239 round( $this->
getConfig()->
get(
'PasswordReminderResendTime' ), 3 )
254 return [
'badipaddress' ];
260 ?
'passwordreset-emailtext-ip'
261 :
'passwordreset-emailtext-user';
267 foreach ( $users
as $user ) {
269 $user->setNewpassword( $password );
270 $user->saveSettings();
271 $passwords[] = $this->
msg(
'passwordreset-emailelement', $user->getName(), $password )
272 ->inLanguage( $userLanguage )->text();
274 $passwordBlock = implode(
"\n\n", $passwords );
276 $this->email = $this->
msg( $msg )->inLanguage( $userLanguage );
277 $this->email->params(
282 round( $this->
getConfig()->
get(
'NewPasswordExpiry' ) / 86400 )
285 $title = $this->
msg(
'passwordreset-emailtitle' )->inLanguage( $userLanguage );
289 if ( isset( $data[
'Capture'] ) && $data[
'Capture'] ) {
297 if ( $this->
result->isGood() ) {
299 } elseif ( isset( $data[
'Capture'] ) && $data[
'Capture'] ) {
306 return [ [
'mailerror', $this->
result->getMessage() ] ];
311 if ( $this->
getUser()->isAllowed(
'passwordreset' ) && $this->email != null ) {
314 if ( $this->
result->isGood() ) {
315 $this->
getOutput()->addWikiMsg(
'passwordreset-emailsent-capture' );
317 $this->
getOutput()->addWikiMsg(
'passwordreset-emailerror-capture',
318 $this->
result->getMessage(), $this->firstUser->getName() );
324 if ( $this->method ===
'email' ) {
325 $this->
getOutput()->addWikiMsg(
'passwordreset-emailsentemail' );
327 $this->
getOutput()->addWikiMsg(
'passwordreset-emailsentusername' );
335 $resetRoutes = $this->
getConfig()->get(
'PasswordResetRoutes' );
338 if ( !is_array( $resetRoutes ) ||
339 !in_array(
true, array_values( $resetRoutes ) )
341 return 'passwordreset-disabled';
345 if ( !$wgAuth->allowPasswordChange() ) {
346 return 'resetpass_forbidden';
350 if ( !$this->
getConfig()->get(
'EnableEmail' ) ) {
351 return 'passwordreset-emaildisabled';
357 return 'blocked-mailpassword';
369 return parent::isListed();
static newFromName($name, $validate= 'valid')
Static factory method for creation from username.
getEmail()
Get the user's e-mail address.
static newFromRow($row, $data=null)
Create a new user object from a user row.
wfGetDB($db, $groups=[], $wiki=false)
Get a Database object.
the array() calling protocol came about after MediaWiki 1.4rc1.
static newMainPage()
Create a new Title for the Main Page.
static rawElement($element, $attribs=[], $contents= '')
Returns an HTML element in a string.
checkExecutePermissions(User $user)
static generateRandomPasswordString($minLength=10)
Generate a random string suitable for a password.
msg()
Wrapper around wfMessage that sets the current context.
getOutput()
Get the OutputPage being used for this instance.
$wgAuth $wgAuth
Authentication plugin.
Special page for requesting a password reset email.
when a variable name is used in a it is silently declared as a new local masking the global
Special page which uses an HTMLForm to handle processing.
getName()
Get the user name, or the IP of an anonymous user.
static selectFields()
Return the list of user fields that should be selected to create a new user object.
sendMail($subject, $body, $from=null, $replyto=null)
Send an e-mail to this user's account.
The User object encapsulates all of the user-specific settings (user_id, name, rights, email address, options, last login time).
wfEscapeWikiText($text)
Escapes the given text so that it may be output using addWikiText() without any linking, formatting, etc.
An error page which can definitely be safely rendered using the OutputPage.
userCanExecute(User $user)
alterForm(HTMLForm $form)
static isValid($ip)
Validate an IP address.
canChangePassword(User $user)
Allows to change the fields on the form that will be generated are created Can be used to omit specific feeds from being outputted You must not use this hook to add use OutputPage::addFeedLink() instead.&$feedLinks conditions will AND in the final query as a Content object as a Content object $title
static run($event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
This directory hold several benchmarking scripts used as a proof of speed or to track PHP performances over time To get somehow accurate result
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
isBlocked($bFromSlave=true)
Check if user is blocked.
getOption($oname, $defaultOverride=null, $ignoreHidden=false)
Get the user's current setting for a given option.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
this hook is for auditing only or null if authentication failed before getting that far $username
$wgMinimalPasswordLength
Specifies the minimal length of a user password.
getId()
Get the user's ID.
getUser()
Shortcut to get the User executing this instance.
isListed()
Hide the password reset page if resets are disabled.
getConfig()
Shortcut to get main config object.
Show an error when a user tries to do something they do not have the necessary permissions for...
static validateEmail($addr)
Does a string look like an e-mail address?
getRequest()
Get the WebRequest being used for this instance.
Show an error when the user hits a rate limit.
onSubmit(array $data)
Process the form.