IMPR: Login forms

This commit is contained in:
Tony Air 2024-03-26 04:22:27 +02:00
parent 141043d219
commit 10d35e92fc
3 changed files with 52 additions and 0 deletions

View File

@ -1,5 +1,8 @@
---
Name: a2nt-cms-niceties-base-extensions
After:
- login-forms
- '#coresecurity'
---
# Basic extensions
SilverStripe\Admin\LeftAndMain:
@ -51,6 +54,10 @@ SilverStripe\Core\Injector\Injector:
class: A2nt\CMSNiceties\Forms\GridField\GridFieldConfig_RelationEditor
SilverStripe\Forms\FormRequestHandler:
class: A2nt\CMSNiceties\Ajax\AjaxFormRequestHandler
SilverStripe\Security\Security:
properties:
Authenticators:
default: '%$A2nt\CMSNiceties\Forms\Authenticator'
SilverStripe\UserForms\Form\UserForm:
extensions:

View File

@ -0,0 +1,13 @@
<?php
namespace A2nt\CMSNiceties\Forms;
use SilverStripe\Security\MemberAuthenticator\MemberAuthenticator;
class Authenticator extends MemberAuthenticator
{
public function getLoginHandler($link)
{
return LoginHandler::create($link, $this);
}
}

View File

@ -0,0 +1,32 @@
<?php
namespace A2nt\CMSNiceties\Forms;
use SilverStripe\Control\Director;
use SilverStripe\Control\HTTPRequest;
use SilverStripe\Security\MemberAuthenticator\LoginHandler as MemberAuthenticatorLoginHandler;
use SilverStripe\Security\MemberAuthenticator\MemberLoginForm;
class LoginHandler extends MemberAuthenticatorLoginHandler
{
private static $allowed_actions = [
'LoginForm',
];
public function doLogin($data, MemberLoginForm $form, HTTPRequest $request)
{
return parent::doLogin($data, $form, $request);
}
public function loginForm()
{
$form = parent::loginForm();
if (Director::isLive() && $form->get_protector()) {
$form->enableSpamProtection();
}
$form->addExtraClass('legacy');
return $form;
}
}