IMPR: Minor form updates

This commit is contained in:
Tony Air 2024-02-02 16:32:15 +02:00
parent 81d8aecea1
commit 70f42541f2
1 changed files with 29 additions and 2 deletions

View File

@ -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' => '<div class="alert alert-success">'.$message.'</div>',
]);
return $json;
/*$response = $ctrl->getResponse();
$response->setBody($json);
die($response->output());*/
}
return Injector::inst()->get(MemberAuthenticator::class)
->getLostPasswordHandler($ctrl->Link())
->passwordsent();