diff --git a/src/Ajax/Ex/AjaxLoginFormControllerEx.php b/src/Ajax/Ex/AjaxLoginFormControllerEx.php index 256a6ea..25781f2 100755 --- a/src/Ajax/Ex/AjaxLoginFormControllerEx.php +++ b/src/Ajax/Ex/AjaxLoginFormControllerEx.php @@ -2,6 +2,7 @@ namespace A2nt\CMSNiceties\Ajax\Ex; +use SilverStripe\Control\Director; use SilverStripe\Core\Extension; use SilverStripe\Core\Injector\Injector; use SilverStripe\Security\MemberAuthenticator\MemberAuthenticator; @@ -26,8 +27,13 @@ class AjaxLoginFormControllerEx extends Extension /* @var Form $form */ $form = $ctrl->LoginForm(); + + //$form->addExtraClass('ajax-form'); $form->setLegend('Sign in to your service account'); - //$form->enableSpamProtection(); + + if ($form->get_protector()) { + $form->enableSpamProtection(); + } return $form; } @@ -43,8 +49,12 @@ class AjaxLoginFormControllerEx extends Extension ->getLostPasswordHandler($ctrl->Link()) ->lostPasswordForm(); + $form->addExtraClass('ajax-form'); $form->setLegend('Restore your password'); - //$form->enableSpamProtection(); + + if ($form->get_protector()) { + $form->enableSpamProtection(); + } return $form; } @@ -53,6 +63,23 @@ class AjaxLoginFormControllerEx extends Extension { $ctrl = $this->owner; + if (Director::is_ajax()) { + $message = _t( + 'SilverStripe\\Security\\Security.PASSWORDRESETSENTTEXT', + "Thank you. A reset link has been sent, provided an account exists for this email address." + ); + + $json = json_encode([ + 'status' => 'success', + 'message' => '
'.$message.'
', + ]); + + return $json; + /*$response = $ctrl->getResponse(); + $response->setBody($json); + die($response->output());*/ + } + return Injector::inst()->get(MemberAuthenticator::class) ->getLostPasswordHandler($ctrl->Link()) ->passwordsent();