59 if ( isset(
$params[
'emailEnabled'] ) ) {
60 $this->emailEnabled = (bool)
$params[
'emailEnabled'];
62 if ( isset(
$params[
'newPasswordExpiry'] ) ) {
63 $this->newPasswordExpiry = (int)
$params[
'newPasswordExpiry'];
65 if ( isset(
$params[
'passwordReminderResendTime'] ) ) {
66 $this->passwordReminderResendTime =
$params[
'passwordReminderResendTime'];
71 parent::setConfig( $config );
73 if ( $this->emailEnabled === null ) {
74 $this->emailEnabled = $this->config->get(
'EnableEmail' );
76 if ( $this->newPasswordExpiry === null ) {
77 $this->newPasswordExpiry = $this->config->get(
'NewPasswordExpiry' );
79 if ( $this->passwordReminderResendTime === null ) {
80 $this->passwordReminderResendTime = $this->config->get(
'PasswordReminderResendTime' );
87 'msg' =>
wfMessage(
'resetpass-temp-emailed' ),
101 if ( isset( $options[
'username'] ) && $this->emailEnabled ) {
120 if ( !
$req ||
$req->username === null ||
$req->password === null ) {
130 $row =
$dbr->selectRow(
133 'user_id',
'user_newpassword',
'user_newpass_time',
148 $pwhash = $this->
getPassword( $row->user_newpassword );
149 if ( !$pwhash->equals(
$req->password ) ) {
169 $row =
$dbr->selectRow(
171 [
'user_newpassword',
'user_newpass_time' ],
197 return (
bool)
wfGetDB( $db )->selectField(
211 return \StatusValue::newGood(
'ignored' );
215 return \StatusValue::newGood();
220 return \StatusValue::newGood(
'ignored' );
225 [
'user_id',
'user_newpass_time' ],
231 return \StatusValue::newGood(
'ignored' );
235 if ( $req->password !== null ) {
238 if ( $req->mailpassword ) {
239 if ( !$this->emailEnabled && !$req->hasBackchannel ) {
240 return \StatusValue::newFatal(
'passwordreset-emaildisabled' );
249 $this->passwordReminderResendTime
250 && $row->user_newpass_time
252 + $this->passwordReminderResendTime * 3600
256 return \StatusValue::newFatal(
'throttled-mailpassword',
257 round( $this->passwordReminderResendTime, 3 ) );
260 if ( !$req->caller ) {
261 return \StatusValue::newFatal(
'passwordreset-nocaller' );
266 return \StatusValue::newFatal(
'passwordreset-nosuchcaller', $req->caller );
287 $newpassTime = $dbw->timestamp();
288 $sendMail = $req->mailpassword;
298 'user_newpassword' => $pwhash->toString(),
299 'user_newpass_time' => $newpassTime,
307 $dbw->onTransactionIdle(
308 function ()
use ( $req ) {
318 return self::TYPE_CREATE;
329 if (
$req->mailpassword && !
$req->hasBackchannel ) {
330 if ( !$this->emailEnabled ) {
332 } elseif ( !
$user->getEmail() ) {
350 if (
$req->username !== null &&
$req->password !== null ) {
352 if (
$req->username !==
$user->getName() ) {
357 if (
$req->mailpassword ) {
359 $this->manager->setAuthenticationSessionData(
'no-email',
true );
372 $req = $res->createRequest;
373 $mailpassword =
$req->mailpassword;
374 $req->mailpassword =
false;
379 if ( $mailpassword ) {
389 return $mailpassword ?
'byemail' : null;
399 if (
$time !== null ) {
401 if ( time() >= $expiry ) {
419 return \Status::newFatal(
'badipaddress' );
423 \Hooks::run(
'User::mailPasswordInternal', [ &$creatingUser, &$ip, &$user ] );
426 $userLanguage = $user->
getOption(
'language' );
427 $subjectMessage =
wfMessage(
'createaccount-title' )->inLanguage( $userLanguage );
428 $bodyMessage =
wfMessage(
'createaccount-text', $ip, $user->
getName(), $password,
429 '<' . $mainPageUrl .
'>', round( $this->newPasswordExpiry / 86400 ) )
430 ->inLanguage( $userLanguage );
432 $status = $user->
sendMail( $subjectMessage->text(), $bodyMessage->text() );
437 $this->logger->warning(
'Could not send account creation email: ' .
438 $status->getWikiText(
false,
false,
'en' ) );
452 return \Status::newFatal(
'noname' );
454 $userLanguage =
$user->getOption(
'language' );
456 $callerName = $callerIsAnon ? $req->caller :
User::newFromName( $req->caller )->getName();
457 $passwordMessage =
wfMessage(
'passwordreset-emailelement',
$user->getName(),
458 $req->password )->inLanguage( $userLanguage );
459 $emailMessage =
wfMessage( $callerIsAnon ?
'passwordreset-emailtext-ip'
460 :
'passwordreset-emailtext-user' )->inLanguage( $userLanguage );
461 $emailMessage->params( $callerName, $passwordMessage->text(), 1,
463 round( $this->newPasswordExpiry / 86400 ) );
464 $emailTitle =
wfMessage(
'passwordreset-emailtitle' )->inLanguage( $userLanguage );
465 return $user->sendMail( $emailTitle->text(), $emailMessage->text() );
static newFromName($name, $validate= 'valid')
Static factory method for creation from username.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
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.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
static getCanonicalName($name, $validate= 'valid')
Given unvalidated user input, return a canonical username, or false if the username is invalid...
static newFatal($message)
Factory function for fatal errors.
Represents an invalid password hash.
it s the revision text itself In either if gzip is the revision text is gzipped $flags
getName()
Get the user name, or the IP of an anonymous user.
const TS_UNIX
Unix time - the number of seconds since 1970-01-01 00:00:00 UTC.
sendMail($subject, $body, $from=null, $replyto=null)
Send an e-mail to this user's account.
wfTimestamp($outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock()-offset Set to overwrite offset parameter in $wgRequest set to ''to unsetoffset-wrap String Wrap the message in html(usually something like"<
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
static isValid($ip)
Validate an IP address.
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
static newGood($value=null)
Factory function for good results.
static run($event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
static getDBOptions($bitfield)
Get an appropriate DB index, options, and fallback DB index for a query.
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
getOption($oname, $defaultOverride=null, $ignoreHidden=false)
Get the user's current setting for a given option.
getRequest()
Get the WebRequest object to use with this object.
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 $req
this hook is for auditing only or null if authentication failed before getting that far $username
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
wfTimestampOrNull($outputtype=TS_UNIX, $ts=null)
Return a formatted timestamp, or null if input is null.
see documentation in includes Linker php for Linker::makeImageLink & $time