mirror of
https://github.com/a2nt/cms-niceties.git
synced 2024-10-22 11:05:46 +02:00
IMPR: Login forms
This commit is contained in:
parent
10d35e92fc
commit
f6b150b866
@ -10,6 +10,7 @@ use SilverStripe\Core\Config\Config;
|
|||||||
use SilverStripe\Core\Extension;
|
use SilverStripe\Core\Extension;
|
||||||
use SilverStripe\Core\Injector\Injector;
|
use SilverStripe\Core\Injector\Injector;
|
||||||
use SilverStripe\Forms\Form;
|
use SilverStripe\Forms\Form;
|
||||||
|
use SilverStripe\Forms\HiddenField;
|
||||||
use SilverStripe\ORM\FieldType\DBHTMLText;
|
use SilverStripe\ORM\FieldType\DBHTMLText;
|
||||||
use SilverStripe\ORM\ValidationResult;
|
use SilverStripe\ORM\ValidationResult;
|
||||||
use SilverStripe\Security\MemberAuthenticator\MemberAuthenticator;
|
use SilverStripe\Security\MemberAuthenticator\MemberAuthenticator;
|
||||||
@ -70,23 +71,17 @@ class AjaxControllerEx extends Extension
|
|||||||
|
|
||||||
public function LoginFormEx()
|
public function LoginFormEx()
|
||||||
{
|
{
|
||||||
$ctrl = $this->owner;
|
$ctrl = Security::singleton();
|
||||||
|
|
||||||
/* @var Form $form */
|
/* @var Form $form */
|
||||||
if (method_exists($ctrl, 'LoginForm')) {
|
|
||||||
$form = $ctrl->LoginForm();
|
|
||||||
} else {
|
|
||||||
$form = $ctrl->getLoginForms()['default'][0];
|
$form = $ctrl->getLoginForms()['default'][0];
|
||||||
}
|
|
||||||
|
|
||||||
self::_processFields($form);
|
self::_processFields($form);
|
||||||
|
|
||||||
//$form->addExtraClass('ajax-form');
|
//$form->addExtraClass('ajax-form');
|
||||||
|
$back = $this->owner->Link();
|
||||||
if (Director::isLive() && $form->get_protector()) {
|
$form->setFormAction('/Security/login/default/LoginForm/?BackURL='.$back);
|
||||||
$form->enableSpamProtection();
|
$form->Fields()
|
||||||
}
|
->push(HiddenField::create('BackURL')->setValue($back));
|
||||||
|
|
||||||
|
|
||||||
$form->setLegend(
|
$form->setLegend(
|
||||||
_t(
|
_t(
|
||||||
@ -207,11 +202,9 @@ class AjaxControllerEx extends Extension
|
|||||||
$url = $req->getURL();
|
$url = $req->getURL();
|
||||||
$url = $url === 'home' ? '/' : $url;
|
$url = $url === 'home' ? '/' : $url;
|
||||||
|
|
||||||
$ajax_res = $ctrl->config()->get('ajax_resources');
|
|
||||||
$graphql_res = $ctrl->config()->get('graphql_resources');
|
|
||||||
$resources = array_merge(
|
$resources = array_merge(
|
||||||
$ajax_res ? $ajax_res : [],
|
$ctrl->config()->get('graphql_resources'),
|
||||||
$graphql_res ? $graphql_res : []
|
$ctrl->config()->get('ajax_resources')
|
||||||
);
|
);
|
||||||
|
|
||||||
$body = $response->getBody();
|
$body = $response->getBody();
|
||||||
|
Loading…
Reference in New Issue
Block a user