diff --git a/core/lib/Thelia/Config/Resources/routing/front.xml b/core/lib/Thelia/Config/Resources/routing/front.xml index 2a1afb2c4..d06585f73 100755 --- a/core/lib/Thelia/Config/Resources/routing/front.xml +++ b/core/lib/Thelia/Config/Resources/routing/front.xml @@ -26,6 +26,7 @@ Thelia\Controller\Front\CustomerController::loginAction + login diff --git a/core/lib/Thelia/Controller/BaseController.php b/core/lib/Thelia/Controller/BaseController.php index 666e8ca32..5e992b258 100755 --- a/core/lib/Thelia/Controller/BaseController.php +++ b/core/lib/Thelia/Controller/BaseController.php @@ -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 { diff --git a/core/lib/Thelia/Controller/Front/BaseFrontController.php b/core/lib/Thelia/Controller/Front/BaseFrontController.php index e92387a83..ed6774c8b 100755 --- a/core/lib/Thelia/Controller/Front/BaseFrontController.php +++ b/core/lib/Thelia/Controller/Front/BaseFrontController.php @@ -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)); } } diff --git a/core/lib/Thelia/Controller/Front/CustomerController.php b/core/lib/Thelia/Controller/Front/CustomerController.php index d753510a6..58d578955 100755 --- a/core/lib/Thelia/Controller/Front/CustomerController.php +++ b/core/lib/Thelia/Controller/Front/CustomerController.php @@ -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()); diff --git a/core/lib/Thelia/Core/Translation/Translator.php b/core/lib/Thelia/Core/Translation/Translator.php index d941fefb7..770091403 100755 --- a/core/lib/Thelia/Core/Translation/Translator.php +++ b/core/lib/Thelia/Core/Translation/Translator.php @@ -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."); diff --git a/core/lib/Thelia/Form/BaseForm.php b/core/lib/Thelia/Form/BaseForm.php index 0eb6b828b..f15dd7525 100755 --- a/core/lib/Thelia/Form/BaseForm.php +++ b/core/lib/Thelia/Form/BaseForm.php @@ -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(); } diff --git a/core/lib/Thelia/Form/CustomerLogin.php b/core/lib/Thelia/Form/CustomerLogin.php index 12b5a2775..3081ceed7 100755 --- a/core/lib/Thelia/Form/CustomerLogin.php +++ b/core/lib/Thelia/Form/CustomerLogin.php @@ -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"; } + } diff --git a/core/lib/Thelia/Tools/URL.php b/core/lib/Thelia/Tools/URL.php index e43591ffc..ffb81992d 100755 --- a/core/lib/Thelia/Tools/URL.php +++ b/core/lib/Thelia/Tools/URL.php @@ -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. diff --git a/templates/default/assets/img/carousel/slider1.png b/templates/default/assets/img/carousel/slider1.png new file mode 100644 index 000000000..422b3ddc0 Binary files /dev/null and b/templates/default/assets/img/carousel/slider1.png differ diff --git a/templates/default/assets/img/carousel/slider2.png b/templates/default/assets/img/carousel/slider2.png new file mode 100644 index 000000000..8eb4049b7 Binary files /dev/null and b/templates/default/assets/img/carousel/slider2.png differ diff --git a/templates/default/assets/img/carousel/slider3.png b/templates/default/assets/img/carousel/slider3.png new file mode 100644 index 000000000..b3630ff60 Binary files /dev/null and b/templates/default/assets/img/carousel/slider3.png differ diff --git a/templates/default/assets/js/script.js b/templates/default/assets/js/script.js index f344b53e5..adbd2c30a 100644 --- a/templates/default/assets/js/script.js +++ b/templates/default/assets/js/script.js @@ -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 /* diff --git a/templates/default/index.html b/templates/default/index.html index 77f6359ae..2c0657dd9 100644 --- a/templates/default/index.html +++ b/templates/default/index.html @@ -7,13 +7,13 @@ @@ -59,7 +59,7 @@
- +