complete login form
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
|
||||
<route id="customer.login.process" path="/customer/login" methods="post">
|
||||
<default key="_controller">Thelia\Controller\Front\CustomerController::loginAction</default>
|
||||
<default key="_view">login</default>
|
||||
</route>
|
||||
|
||||
<route id="customer.login.view" path="/login">
|
||||
|
||||
@@ -179,7 +179,14 @@ class BaseController extends ContainerAware
|
||||
return $form;
|
||||
}
|
||||
else {
|
||||
throw new FormValidationException(sprintf("Missing or invalid data: %s", $this->getErrorMessages($form)));
|
||||
$errorMessage = null;
|
||||
if ($form->get("error_message")->getData() != null) {
|
||||
$errorMessage = $form->get("error_message")->getData();
|
||||
} else {
|
||||
$errorMessage = sprintf("Missing or invalid data: %s", $this->getErrorMessages($form));
|
||||
}
|
||||
|
||||
throw new FormValidationException($errorMessage);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Controller\Front;
|
||||
|
||||
use Symfony\Component\Routing\Router;
|
||||
use Thelia\Controller\BaseController;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
@@ -34,8 +35,8 @@ class BaseFrontController extends BaseController
|
||||
*
|
||||
* @see \Thelia\Controller\BaseController::getRouteFromRouter()
|
||||
*/
|
||||
protected function getRoute($routeId) {
|
||||
return $this->getRouteFromRouter('router.front', $routeId);
|
||||
protected function getRoute($routeId, $parameters = array(), $referenceType = Router::ABSOLUTE_PATH) {
|
||||
return $this->getRouteFromRouter('router.front', $routeId, $parameters, $referenceType);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,7 +45,7 @@ class BaseFrontController extends BaseController
|
||||
* @param unknown $routeId the route ID, as found in Config/Resources/routing/admin.xml
|
||||
* @param unknown $urlParameters the URL parametrs, as a var/value pair array
|
||||
*/
|
||||
public function redirectToRoute($routeId, $urlParameters = array()) {
|
||||
$this->redirect(URL::getInstance()->absoluteUrl($this->getRoute($routeId), $urlParameters));
|
||||
public function redirectToRoute($routeId, $urlParameters = array(), $referenceType = Router::ABSOLUTE_PATH) {
|
||||
$this->redirect(URL::getInstance()->absoluteUrl($this->getRoute($routeId, array(), $referenceType), $urlParameters));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ use Thelia\Core\Factory\ActionEventFactory;
|
||||
use Thelia\Tools\URL;
|
||||
use Thelia\Log\Tlog;
|
||||
use Thelia\Core\Security\Exception\WrongPasswordException;
|
||||
use Symfony\Component\Routing\Router;
|
||||
|
||||
/**
|
||||
* Class CustomerController
|
||||
@@ -167,16 +168,25 @@ class CustomerController extends BaseFrontController
|
||||
|
||||
}
|
||||
catch (FormValidationException $e) {
|
||||
|
||||
if ($request->request->has("account")) {
|
||||
$account = $request->request->get("account");
|
||||
$form = $customerLoginForm->getForm();
|
||||
if($account == 0 && $form->get("email")->getData() !== null) {
|
||||
$this->redirectToRoute("customer.create.view", array("email" => $form->get("email")->getData()));
|
||||
}
|
||||
}
|
||||
|
||||
$message = sprintf("Please check your input: %s", $e->getMessage());
|
||||
}
|
||||
catch(UsernameNotFoundException $e) {
|
||||
$message = "This customer email was not found.";
|
||||
$message = "Wrong email or password. Please try again";
|
||||
}
|
||||
catch (WrongPasswordException $e) {
|
||||
$message = "Wrong password. Please try again.";
|
||||
$message = "Wrong email or password. Please try again";
|
||||
}
|
||||
catch(AuthenticationException $e) {
|
||||
$message = "Sorry, we failed to authentify you. Please try again.";
|
||||
$message = "Wrong email or password. Please try again";
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
$message = sprintf("Sorry, an error occured: %s", $e->getMessage());
|
||||
|
||||
@@ -20,7 +20,7 @@ class Translator extends BaseTranslator
|
||||
* Return this class instance, only once instanciated.
|
||||
*
|
||||
* @throws \RuntimeException if the class has not been instanciated.
|
||||
* @return Thelia\Core\Translation\Translator the instance.
|
||||
* @return \Thelia\Core\Translation\Translator the instance.
|
||||
*/
|
||||
public static function getInstance() {
|
||||
if (self::$instance == null) throw new \RuntimeException("Translator instance is not initialized.");
|
||||
|
||||
@@ -102,6 +102,10 @@ abstract class BaseForm
|
||||
$this->formBuilder->add("success_url", "text");
|
||||
}
|
||||
|
||||
if (! $this->formBuilder->has('error_message')) {
|
||||
$this->formBuilder->add("error_message", "text");
|
||||
}
|
||||
|
||||
$this->form = $this->formBuilder->getForm();
|
||||
}
|
||||
|
||||
|
||||
@@ -22,24 +22,38 @@
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints\Callback;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Symfony\Component\Validator\Constraints\Email;
|
||||
use Symfony\Component\Validator\ExecutionContextInterface;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Model\CustomerQuery;
|
||||
|
||||
class CustomerLogin extends BaseForm
|
||||
{
|
||||
protected function buildForm()
|
||||
{
|
||||
$this->formBuilder
|
||||
->add("email", "text", array(
|
||||
->add("email", "email", array(
|
||||
"constraints" => array(
|
||||
new NotBlank(),
|
||||
new Email()
|
||||
)
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("Please enter your email address"),
|
||||
"label_attr" => array(
|
||||
"for" => "email"
|
||||
),
|
||||
"required" => true
|
||||
))
|
||||
->add("password", "password", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
)
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("Please enter your password"),
|
||||
"label_attr" => array(
|
||||
"for" => "password"
|
||||
),
|
||||
"required" => true
|
||||
))
|
||||
->add("remember_me", "checkbox")
|
||||
;
|
||||
@@ -49,4 +63,5 @@ class CustomerLogin extends BaseForm
|
||||
{
|
||||
return "thelia_customer_login";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -121,6 +121,11 @@ class URL
|
||||
|
||||
$base_url = $this->getBaseUrl();
|
||||
|
||||
// TODO fix this ugly patch
|
||||
if(strpos($path, "index_dev.php")) {
|
||||
$path = str_replace('index_dev.php', '', $path);
|
||||
}
|
||||
|
||||
// If only a path is requested, be sure to remove the script name (index.php or index_dev.php), if any.
|
||||
if ($path_only == self::PATH_TO_FILE) {
|
||||
// As the base_url always ends with '/', if we don't find / at the end, we have a script.
|
||||
|
||||
BIN
templates/default/assets/img/carousel/slider1.png
Normal file
BIN
templates/default/assets/img/carousel/slider1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 698 KiB |
BIN
templates/default/assets/img/carousel/slider2.png
Normal file
BIN
templates/default/assets/img/carousel/slider2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 766 KiB |
BIN
templates/default/assets/img/carousel/slider3.png
Normal file
BIN
templates/default/assets/img/carousel/slider3.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 298 KiB |
@@ -47,7 +47,7 @@
|
||||
}
|
||||
|
||||
// Login
|
||||
var $form_login = $('#form-login');
|
||||
/* var $form_login = $('#form-login');
|
||||
if($form_login.size() > 0) {
|
||||
$form_login.on('change.account', ':radio', function(){
|
||||
if($(this).val() === '0')
|
||||
@@ -55,7 +55,7 @@
|
||||
else
|
||||
$('#password', $form_login).prop('disabled', false); // Enabled
|
||||
}).find(':radio:checked').trigger('change.account');
|
||||
}
|
||||
}*/
|
||||
|
||||
// Forgot Password
|
||||
/*
|
||||
|
||||
@@ -7,13 +7,13 @@
|
||||
<div class="carousel-wrapper">
|
||||
<div class="carousel-inner">
|
||||
<figure class="item active">
|
||||
{images file='assets/img/carousel/1200x390.png'}<img src="{$asset_url}" alt="img1">{/images}
|
||||
{images file='assets/img/carousel/slider1.png'}<img src="{$asset_url}" alt="img1">{/images}
|
||||
</figure>
|
||||
<figure class="item">
|
||||
{images file='assets/img/carousel/1200x390.png'}<img src="{$asset_url}" alt="img2">{/images}
|
||||
{images file='assets/img/carousel/slider2.png'}<img src="{$asset_url}" alt="img2">{/images}
|
||||
</figure>
|
||||
<figure class="item">
|
||||
{images file='assets/img/carousel/1200x390.png'}<img src="{$asset_url}" alt="img3">{/images}
|
||||
{images file='assets/img/carousel/slider3.png'}<img src="{$asset_url}" alt="img3">{/images}
|
||||
</figure>
|
||||
</div>
|
||||
</div>
|
||||
@@ -59,7 +59,7 @@
|
||||
|
||||
<div class="product-price">
|
||||
<div class="price-container" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
|
||||
<meta itemprop="currency" content="USD"> <!-- List of currency : The currency used to describe the product price, in three-letter ISO format. -->
|
||||
<meta itemprop="currency" content="{currency attr="code"}"> <!-- List of currency : The currency used to describe the product price, in three-letter ISO format. -->
|
||||
<link itemprop="availability" href="http://schema.org/InStock" content="In Stock" />
|
||||
<!-- List of availibility :
|
||||
out_of_stock : http://schema.org/OutOfStock
|
||||
|
||||
@@ -15,37 +15,63 @@
|
||||
|
||||
<div class="main">
|
||||
<article class="col-main" role="main" aria-labelledby="main-label">
|
||||
<h1 id="main-label" class="page-header">Login</h1>
|
||||
<form id="form-login" action="" method="post" role="form">
|
||||
<h1 id="main-label" class="page-header">{intl l="Login"}</h1>
|
||||
{form name="thelia.customer.login"}
|
||||
<form id="form-login" action="{url path="/customer/login"}" method="post" role="form" {form_enctype form=$form}>
|
||||
{if #form_error}<div class="alert alert-danger">#form_error_message</div>{/if}
|
||||
{form_field form=$form field='success_url'}
|
||||
<input type="hidden" name="{$name}" value="{navigate to="return_to"}" /> {* the url the user is redirected to on login success *}
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='error_message'}
|
||||
<input type="hidden" name="{$name}" value="{intl l="missing or invalid data"}" /> {* the url the user is redirected to on login success *}
|
||||
{/form_field}
|
||||
{form_hidden_fields form=$form}
|
||||
<fieldset>
|
||||
<div class="form-group group-email">
|
||||
<label for="email">Please enter your email address</label>
|
||||
<input type="email" name="email" id="email" class="form-control" value="" aria-required="true" autofocus required>
|
||||
</div>
|
||||
{form_field form=$form field="email"}
|
||||
<div class="form-group group-email {if $error}has-error{/if} ">
|
||||
<label for="{$label_attr.for}">{$label}</label>
|
||||
<div class="control-input">
|
||||
<input type="email" name="{$name}" id="{$label_attr.for}" value="{$value}" class="form-control" {$attr} aria-required="true" autofocus required>
|
||||
{if $error}
|
||||
<span class="help-block"><i class="icon-remove"></i> {$message}</span>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
<fieldset>
|
||||
<legend>Do you have an account?</legend>
|
||||
<legend>{intl l="Do you have an account?"}</legend>
|
||||
<div class="radio radio-account0" >
|
||||
<label for="account0">
|
||||
<input type="radio" name="account" id="account0" data-toggle="password" value="0" <?php if(!(isset($_POST['account']) && $_POST['account'] == '1')) { echo ' checked'; }?>> No, I am a new customer.
|
||||
<input type="radio" name="account" id="account0" data-toggle="password" value="0" > {intl l="No, I am a new customer."}
|
||||
</label>
|
||||
</div>
|
||||
<div class="radio radio-account1">
|
||||
<label for="account1">
|
||||
<input type="radio" name="account" id="account1" data-toggle="password" value="1"<?php if(isset($_POST['account']) && $_POST['account'] == '1' ) { echo ' checked'; }?>> Yes, I have a password :
|
||||
<input type="radio" name="account" id="account1" data-toggle="password" value="1" checked> {intl l="Yes, I have a password :"}
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group group-password">
|
||||
<label for="password" class="sr-only">Please enter your password</label>
|
||||
<input type="password" name="password" id="password" class="form-control" autocomplete="off">
|
||||
{form_field form=$form field="password"}
|
||||
<div class="form-group group-password {if $error}has-error{/if} ">
|
||||
<label for="{$label_attr.for}" class="sr-only">{$label}</label>
|
||||
<div class="control-input">
|
||||
<input type="password" name="{$name}" id="{$label_attr.for}" class="form-control" autocomplete="off">
|
||||
{if $error}
|
||||
<span class="help-block"><i class="icon-remove"></i> {$message}</span>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{/form_field}
|
||||
</fieldset>
|
||||
</fieldset>
|
||||
|
||||
<div class="group-btn">
|
||||
<a href="password.php" class="forgot-password">Forgot your Password ?</a>
|
||||
<button type="submit" class="btn btn-login">Next</button>
|
||||
<a href="{url path="/customer/password"}" class="forgot-password">{intl l="Forgot your Password ?"}</a>
|
||||
<button type="submit" class="btn btn-login">{intl l="Next"}</button>
|
||||
</div>
|
||||
</form>
|
||||
{/form}
|
||||
</article>
|
||||
</div>
|
||||
{/block}
|
||||
Reference in New Issue
Block a user