Source of file ShowLoginAttemptsExtension.php
Size: 1,566 Bytes - Last Modified: 2021-12-23T10:08:54+00:00
/var/www/docs.ssmods.com/process/src/src/Extensions/ShowLoginAttemptsExtension.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 | <?php /** * Display login attempts in CMS * * @category SilverStripe_Project * @package SDLT * @author Catalyst I.T. SilverStripe Team 2018 <silverstripedev@catalyst.net.nz> * @copyright NZ Transport Agency * @license BSD-3 * @link https://www.catalyst.net.nz * **/ namespace NZTA\SDLT\Extension; use SilverStripe\ORM\DataExtension; use SilverStripe\Forms\FieldList; use SilverStripe\Forms\GridField\GridField; use SilverStripe\Forms\GridField\GridFieldConfig_RecordViewer; use SilverStripe\Security\LoginAttempt; use SilverStripe\Core\Convert; /** * Display login attempts in CMS */ class ShowLoginAttemptsExtension extends DataExtension { /** * new database fields * * @var array */ private static $db = [ 'Hostname' => 'Varchar(255)' ]; /** * Update CMS fields * * @param FieldList $fields fields * @return void */ public function updateCMSFields(FieldList $fields) { $fields->addFieldToTab( 'Root.LoginAttempts', GridField::create( 'LoginAttempts', 'LoginAttempts', LoginAttempt::get()->filter('Member.ID', $this->owner->ID), GridFieldConfig_RecordViewer::create(25) ) ); } /** * Record hostname before writing record * * @return void */ public function onBeforeWrite() { if (isset($_SERVER['REMOTE_HOST'])) { $this->owner->Hostname = Convert::raw2sql($_SERVER['REMOTE_HOST']); } } } |