An errorred form is now passed to the Form smarty plugin through the parser context instead of the
session
This commit is contained in:
@@ -36,6 +36,7 @@ use Thelia\Core\Security\Exception\AuthenticationException;
|
||||
use Thelia\Core\Security\SecurityContext;
|
||||
use Thelia\Tools\URL;
|
||||
use Thelia\Tools\Redirect;
|
||||
use Thelia\Core\Template\ParserContext;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -100,6 +101,16 @@ class BaseAdminController extends ContainerAware
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the parser context,
|
||||
*
|
||||
* @return ParserContext
|
||||
*/
|
||||
protected function getParserContext($context = false)
|
||||
{
|
||||
return $this->container->get('thelia.parser.context');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the security context, by default in admin mode.
|
||||
*
|
||||
|
||||
@@ -49,11 +49,11 @@ class SessionController extends BaseAdminController {
|
||||
|
||||
public function checkLoginAction()
|
||||
{
|
||||
$form = new AdminLogin($this->getRequest());
|
||||
$adminLoginForm = new AdminLogin($this->getRequest());
|
||||
|
||||
$request = $this->getRequest();
|
||||
|
||||
$authenticator = new AdminUsernamePasswordFormAuthenticator($request, $form);
|
||||
$authenticator = new AdminUsernamePasswordFormAuthenticator($request, $adminLoginForm);
|
||||
|
||||
try {
|
||||
$user = $authenticator->getAuthentifiedUser();
|
||||
@@ -65,7 +65,7 @@ class SessionController extends BaseAdminController {
|
||||
AdminLog::append("Authentication successuful", $request, $user);
|
||||
|
||||
// Redirect to the success URL
|
||||
return Redirect::exec($form->getSuccessUrl());
|
||||
return Redirect::exec($adminLoginForm->getSuccessUrl());
|
||||
}
|
||||
catch (ValidatorException $ex) {
|
||||
|
||||
@@ -87,12 +87,14 @@ class SessionController extends BaseAdminController {
|
||||
$message = "Unable to process your request. Please try again.";
|
||||
}
|
||||
|
||||
// Store the form name in session (see Form Smarty plugin to find usage of this parameter)
|
||||
$request->getSession()->setErrorFormName($form->getName());
|
||||
// Store error information in the form
|
||||
$adminLoginForm->setError(true);
|
||||
$adminLoginForm->setErrorMessage($message);
|
||||
|
||||
// Display the login form again, with an error message if required
|
||||
return $this->render("login.html", array(
|
||||
"message" => $message
|
||||
));
|
||||
// Store the form name in session (see Form Smarty plugin to find usage of this parameter)
|
||||
$this->getParserContext()->setErrorForm($adminLoginForm);
|
||||
|
||||
// Display the login form again
|
||||
return $this->render("login.html");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user