MediaWiki  1.34.0
EmailNotificationSecondaryAuthenticationProvider.php
Go to the documentation of this file.
1 <?php
2 
3 namespace MediaWiki\Auth;
4 
5 use Config;
6 
15 {
18 
24  public function __construct( $params = [] ) {
25  if ( isset( $params['sendConfirmationEmail'] ) ) {
26  $this->sendConfirmationEmail = (bool)$params['sendConfirmationEmail'];
27  }
28  }
29 
30  public function setConfig( Config $config ) {
31  parent::setConfig( $config );
32 
33  if ( $this->sendConfirmationEmail === null ) {
34  $this->sendConfirmationEmail = $this->config->get( 'EnableEmail' )
35  && $this->config->get( 'EmailAuthentication' );
36  }
37  }
38 
39  public function getAuthenticationRequests( $action, array $options ) {
40  return [];
41  }
42 
43  public function beginSecondaryAuthentication( $user, array $reqs ) {
45  }
46 
47  public function beginSecondaryAccountCreation( $user, $creator, array $reqs ) {
48  if (
49  $this->sendConfirmationEmail
50  && $user->getEmail()
51  && !$this->manager->getAuthenticationSessionData( 'no-email' )
52  ) {
53  // TODO show 'confirmemail_oncreate'/'confirmemail_sendfailed' message
54  wfGetDB( DB_MASTER )->onTransactionCommitOrIdle(
55  function () use ( $user ) {
56  $user = $user->getInstanceForUpdate();
57  $status = $user->sendConfirmationMail();
58  $user->saveSettings();
59  if ( !$status->isGood() ) {
60  $this->logger->warning( 'Could not send confirmation email: ' .
61  $status->getWikiText( false, false, 'en' ) );
62  }
63  },
64  __METHOD__
65  );
66  }
67 
69  }
70 }
MediaWiki\Auth\AbstractSecondaryAuthenticationProvider
A base class that implements some of the boilerplate for a SecondaryAuthenticationProvider.
Definition: AbstractSecondaryAuthenticationProvider.php:30
MediaWiki\Auth\EmailNotificationSecondaryAuthenticationProvider\getAuthenticationRequests
getAuthenticationRequests( $action, array $options)
Return the applicable list of AuthenticationRequests.
Definition: EmailNotificationSecondaryAuthenticationProvider.php:39
MediaWiki\Auth\EmailNotificationSecondaryAuthenticationProvider\beginSecondaryAuthentication
beginSecondaryAuthentication( $user, array $reqs)
Start an authentication flow.
Definition: EmailNotificationSecondaryAuthenticationProvider.php:43
MediaWiki\Auth\EmailNotificationSecondaryAuthenticationProvider\$sendConfirmationEmail
bool $sendConfirmationEmail
Definition: EmailNotificationSecondaryAuthenticationProvider.php:17
MediaWiki\Auth\AuthenticationResponse\newAbstain
static newAbstain()
Definition: AuthenticationResponse.php:170
Config
Interface for configuration instances.
Definition: Config.php:28
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:2575
DB_MASTER
const DB_MASTER
Definition: defines.php:26
MediaWiki\Auth\EmailNotificationSecondaryAuthenticationProvider\__construct
__construct( $params=[])
Definition: EmailNotificationSecondaryAuthenticationProvider.php:24
MediaWiki\$action
string $action
Cache what action this request is.
Definition: MediaWiki.php:48
$status
return $status
Definition: SyntaxHighlight.php:347
MediaWiki\Auth\EmailNotificationSecondaryAuthenticationProvider
Handles email notification / email address confirmation for account creation.
Definition: EmailNotificationSecondaryAuthenticationProvider.php:13
MediaWiki\Auth
Definition: AbstractAuthenticationProvider.php:22
MediaWiki\Auth\AuthenticationResponse\newPass
static newPass( $username=null)
Definition: AuthenticationResponse.php:134
MediaWiki\Auth\EmailNotificationSecondaryAuthenticationProvider\beginSecondaryAccountCreation
beginSecondaryAccountCreation( $user, $creator, array $reqs)
Start an account creation flow.
Definition: EmailNotificationSecondaryAuthenticationProvider.php:47
MediaWiki\Auth\EmailNotificationSecondaryAuthenticationProvider\setConfig
setConfig(Config $config)
Set configuration.
Definition: EmailNotificationSecondaryAuthenticationProvider.php:30
MediaWiki\Auth\AbstractAuthenticationProvider\$config
Config $config
Definition: AbstractAuthenticationProvider.php:38