Source of file MemberExtension.php
Size: 1,759 Bytes - Last Modified: 2021-12-23T10:06:51+00:00
/var/www/docs.ssmods.com/process/src/code/extensions/MemberExtension.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 | <?php namespace SecurityHardener\Extensions; use SecurityHardener\Emails\LockedOutNotification; class MemberExtension extends \DataExtension { /** * @var array */ private static $db = [ 'LockedOutNotificationSent' => 'Boolean', ]; /** * Send an email (if configured) on lockout. */ public function registerFailedLogin() { if ($this->owner->isLockedOut() && !$this->owner->LockedOutNotificationSent && ($siteConfig = \SiteConfig::current_site_config()) && $siteConfig->LockoutNotificationEmail ) { $mail = LockedOutNotification::create( $from = null, $to = $siteConfig->LockoutNotificationEmail )->populateTemplate([ 'Title' => _t('LockedOutNotification.title', 'Member locked out'), 'Member' => $this->owner, 'Attempts' => \Member::config()->lock_out_after_incorrect_logins, ]); $this->owner->LockedOutNotificationSent = (boolean)$mail->send(); } } /** * Clear LockedOutNotificationSent on login */ public function memberLoggedIn() { // Don't set column if its not built yet (the login might be precursor to a /dev/build...) if (array_key_exists('LockedOutNotificationSent', \DB::fieldList('Member'))) { $this->owner->LockedOutNotificationSent = null; $this->owner->write(); } } /** * @return \DataObject */ public function getLastFailedLoginAttempt() { return \LoginAttempt::get()->filter([ 'Status' => 'Failure', 'MemberID' => $this->owner->ID ])->last(); } } |