Source of file YubikeyForm.php
Size: 1,950 Bytes - Last Modified: 2021-12-24T06:47:50+00:00
/var/www/docs.ssmods.com/process/src/src/Forms/YubikeyForm.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 | <?php namespace Firesphere\YubiAuth\Forms; use SilverStripe\Control\RequestHandler; use SilverStripe\Forms\FieldList; use SilverStripe\Forms\FormAction; use SilverStripe\Forms\HiddenField; use SilverStripe\Forms\PasswordField; use SilverStripe\Forms\RequiredFields; use SilverStripe\Security\LoginForm; /** * Class YubikeyForm * @package Firesphere\YubiAuth\Forms */ class YubikeyForm extends LoginForm { /** * YubikeyForm constructor. * @param RequestHandler|null $controller * @param string $name */ public function __construct( RequestHandler $controller = null, $name = self::DEFAULT_NAME ) { $this->controller = $controller; $fields = $this->getFormFields(); $actions = $this->getFormActions(); $validator = RequiredFields::create(['yubiauth']); parent::__construct($controller, $name, $fields, $actions, $validator); } /** * @return FieldList|static */ public function getFormFields() { $fields = FieldList::create( [ PasswordField::create( 'yubiauth', _t(self::class . '.YUBIKEYSECONDFACTORFIELD', 'Yubikey second factor authentication') ) ] ); $backURL = $this->controller->getRequest()->getVar('BackURL'); if ($backURL) { $fields->push(HiddenField::create('BackURL', $backURL)); } return $fields; } /** * @return FieldList|static */ public function getFormActions() { $action = FieldList::create( [ FormAction::create('validateToken', _t(self::class . '.VALIDATE', 'Validate')) ] ); return $action; } /** * @return string */ public function getAuthenticatorName() { return _t(self::class . '.TITLE', 'Yubikey authentication'); } } |