mirror of
https://github.com/a2nt/cms-niceties.git
synced 2024-06-16 09:01:31 +02:00
Compare commits
3 Commits
141043d219
...
7d0b766882
Author | SHA1 | Date | |
---|---|---|---|
7d0b766882 | |||
f6b150b866 | |||
10d35e92fc |
|
@ -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:
|
||||
|
|
|
@ -10,6 +10,7 @@ use SilverStripe\Core\Config\Config;
|
|||
use SilverStripe\Core\Extension;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\Forms\Form;
|
||||
use SilverStripe\Forms\HiddenField;
|
||||
use SilverStripe\ORM\FieldType\DBHTMLText;
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\Security\MemberAuthenticator\MemberAuthenticator;
|
||||
|
@ -70,23 +71,17 @@ class AjaxControllerEx extends Extension
|
|||
|
||||
public function LoginFormEx()
|
||||
{
|
||||
$ctrl = $this->owner;
|
||||
$ctrl = Security::singleton();
|
||||
|
||||
/* @var Form $form */
|
||||
if (method_exists($ctrl, 'LoginForm')) {
|
||||
$form = $ctrl->LoginForm();
|
||||
} else {
|
||||
$form = $ctrl->getLoginForms()['default'][0];
|
||||
}
|
||||
|
||||
self::_processFields($form);
|
||||
|
||||
//$form->addExtraClass('ajax-form');
|
||||
|
||||
if (Director::isLive() && $form->get_protector()) {
|
||||
$form->enableSpamProtection();
|
||||
}
|
||||
|
||||
$back = $this->owner->Link();
|
||||
$form->setFormAction('/Security/login/default/LoginForm/?BackURL='.$back);
|
||||
$form->Fields()
|
||||
->push(HiddenField::create('BackURL')->setValue($back));
|
||||
|
||||
$form->setLegend(
|
||||
_t(
|
||||
|
@ -207,11 +202,9 @@ class AjaxControllerEx extends Extension
|
|||
$url = $req->getURL();
|
||||
$url = $url === 'home' ? '/' : $url;
|
||||
|
||||
$ajax_res = $ctrl->config()->get('ajax_resources');
|
||||
$graphql_res = $ctrl->config()->get('graphql_resources');
|
||||
$resources = array_merge(
|
||||
$ajax_res ? $ajax_res : [],
|
||||
$graphql_res ? $graphql_res : []
|
||||
$ctrl->config()->get('graphql_resources'),
|
||||
$ctrl->config()->get('ajax_resources')
|
||||
);
|
||||
|
||||
$body = $response->getBody();
|
||||
|
|
13
src/Forms/Authentificator.php
Normal file
13
src/Forms/Authentificator.php
Normal 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);
|
||||
}
|
||||
}
|
32
src/Forms/LoginHandler.php
Normal file
32
src/Forms/LoginHandler.php
Normal 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 (self::config()->get('enable_captcha') && Director::isLive() && $form->get_protector()) {
|
||||
$form->enableSpamProtection();
|
||||
}
|
||||
$form->addExtraClass('legacy');
|
||||
|
||||
return $form;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user