+
{if isset($errors)}
{if $nbErrors > 1}{l s='There are'}{else}{l s='There is'}{/if} {$nbErrors}{if $nbErrors > 1} {l s='errors'}{else} {l s='error'}{/if}
@@ -48,59 +48,66 @@
{/if}
- {if !isset($wrong_folder_name)}
-
- {else}
{$shop_name}
-
-
{l s='For security reasons, you cannot connect to the Back Office until after you have:'}
-
- - {l s='deleted the /install folder'}
- - {l s='renamed the /admin folder (e.g. /admin123%d)' sprintf=$randomNb}
-
-
{l s='Please then access this page by the new URL (e.g. http://www.yoursite.com/admin123%d)' sprintf=$randomNb}
+ {if !isset($wrong_folder_name)}
+
+
+
+ {else}
+
+
{l s='For security reasons, you cannot connect to the Back Office until after you have:'}
+
+ - {l s='deleted the /install folder'}
+ - {l s='renamed the /admin folder (e.g. /admin123%d)' sprintf=$randomNb}
+
+
{l s='Please then access this page by the new URL (e.g. http://www.yoursite.com/admin123%d)' sprintf=$randomNb}
{/if}
-
diff --git a/controllers/admin/AdminLoginController.php b/controllers/admin/AdminLoginController.php
index 2b48ac340..1313cbf5c 100755
--- a/controllers/admin/AdminLoginController.php
+++ b/controllers/admin/AdminLoginController.php
@@ -69,31 +69,27 @@ class AdminLoginControllerCore extends AdminController
if (file_exists(_PS_ADMIN_DIR_.'/../install') || file_exists(_PS_ADMIN_DIR_.'/../admin')
|| (file_exists(_PS_ADMIN_DIR_.'/../install-dev') && (!defined('_PS_MODE_DEV_') || !_PS_MODE_DEV_)))
- $this->context->smarty->assign(
- array(
+ $this->context->smarty->assign(array(
'randomNb' => rand(100, 999),
- 'wrong_folder_name' => true)
- );
+ 'wrong_folder_name' => true
+ ));
// Redirect to admin panel
- if (isset($_GET['redirect']) && Validate::isControllerName($_GET['redirect']))
- $this->context->smarty->assign(array('redirect' => Tools::getValue('redirect')));
+ if (Tools::isSubmit('redirect') && Validate::isControllerName(Tools::getValue('redirect')))
+ $this->context->smarty->assign('redirect', Tools::getValue('redirect'));
else
{
$tab = new Tab((int)$this->context->employee->default_tab);
- $url = $this->context->link->getAdminLink($tab->class_name);
- $this->context->smarty->assign(array('redirect' => $url));
+ $this->context->smarty->assign('redirect', $this->context->link->getAdminLink($tab->class_name));
}
if ($nbErrors = count($this->errors))
- $this->context->smarty->assign(
- array(
- 'errors' => $this->errors,
- 'nbErrors' => $nbErrors,
- 'shop_name' => Tools::safeOutput(Configuration::get('PS_SHOP_NAME')),
- 'disableDefaultErrorOutPut' => true,
- )
- );
+ $this->context->smarty->assign(array(
+ 'errors' => $this->errors,
+ 'nbErrors' => $nbErrors,
+ 'shop_name' => Tools::safeOutput(Configuration::get('PS_SHOP_NAME')),
+ 'disableDefaultErrorOutPut' => true,
+ ));
$this->setMedia();
$this->initHeader();
parent::initContent();
@@ -132,11 +128,10 @@ class AdminLoginControllerCore extends AdminController
$this->errors[] = Tools::displayError('E-mail is empty');
elseif (!Validate::isEmail($email))
$this->errors[] = Tools::displayError('Invalid e-mail address');
-
-
+
if (empty($passwd))
$this->errors[] = Tools::displayError('Password is blank');
- else if (!Validate::isPasswd($passwd))
+ elseif (!Validate::isPasswd($passwd))
$this->errors[] = Tools::displayError('Invalid password');
if (!count($this->errors))
@@ -191,8 +186,8 @@ class AdminLoginControllerCore extends AdminController
$employee = new Employee();
if (!$employee->getByemail($email) || !$employee)
$this->errors[] = Tools::displayError('This account does not exist');
- else if ((strtotime($employee->last_passwd_gen.'+'.Configuration::get('PS_PASSWD_TIME_BACK').' minutes') - time()) > 0)
- $this->errors[] = Tools::displayError('You can regenerate your password only every').' '.Configuration::get('PS_PASSWD_TIME_BACK').' '.Tools::displayError('minute(s)');
+ elseif ((strtotime($employee->last_passwd_gen.'+'.Configuration::get('PS_PASSWD_TIME_BACK').' minutes') - time()) > 0)
+ $this->errors[] = Tools::displayError('You can regenerate your password only every').' '.Configuration::get('PS_PASSWD_TIME_BACK').' '.Tools::displayError('minute(s)');
}
if (_PS_MODE_DEMO_)
$errors[] = Tools::displayError('This functionality has been disabled.');
@@ -208,16 +203,22 @@ class AdminLoginControllerCore extends AdminController
else
{
$params = array(
- '{email}' => $employee->email,
- '{lastname}' => $employee->lastname,
- '{firstname}' => $employee->firstname,
- '{passwd}' => $pwd
- );
+ '{email}' => $employee->email,
+ '{lastname}' => $employee->lastname,
+ '{firstname}' => $employee->firstname,
+ '{passwd}' => $pwd
+ );
if (Mail::Send((int)Configuration::get('PS_LANG_DEFAULT'), 'password', Mail::l('Your new admin password', (int)Configuration::get('PS_LANG_DEFAULT')), $params, $employee->email, $employee->firstname.' '.$employee->lastname))
- die(Tools::jsonEncode(array('hasErrors' => false, 'confirm' => $this->l('Your password has been e-mailed to you'))));
+ die(Tools::jsonEncode(array(
+ 'hasErrors' => false,
+ 'confirm' => $this->l('Your password has been e-mailed to you')
+ )));
else
- die(Tools::jsonEncode(array('hasErrors' => true, 'errors' => array(Tools::displayError('An error occurred during your password change.')))));
+ die(Tools::jsonEncode(array(
+ 'hasErrors' => true,
+ 'errors' => array(Tools::displayError('An error occurred during your password change.'))
+ )));
}
}
diff --git a/css/login.css b/css/login.css
index f3f3640cd..29fcd7136 100644
--- a/css/login.css
+++ b/css/login.css
@@ -1,5 +1,3 @@
-/* CSS Document */
-
body {
margin: 0;
padding: 0;
@@ -11,9 +9,6 @@ body {
background-position: center center;
}
-body #main {
- }
-
h1 {
color: #902F52;
font-size: 20pt;
@@ -60,7 +55,6 @@ input:focus, textarea:focus {
}
/* CONTENT */
-
#container {
width: 464px;
margin: 12% auto 1em;
@@ -68,7 +62,6 @@ input:focus, textarea:focus {
}
#login {
- height: 313px;
color: #383838;
text-align: left;
font-weight: bold;
@@ -83,38 +76,26 @@ input:focus, textarea:focus {
text-shadow:0 1px 0 #fff;
}
-#login a {
- color:#3A6EA7;
-}
-#login label {
- text-shadow: 0 1px 0 #fff;
-}
+#login a { color:#3A6EA7; }
+#login label { text-shadow: 0 1px 0 #fff; }
#login form {
border-top:1px solid #fff;
margin: 0;
- padding: 40px 30px 25px 30px;
+ padding: 30px;
}
-#login #submit {
+#login .submit {
margin: 1em 1px;
padding: 0;
display: block;
float:left;
}
-#login #submit input {
+#login .submit input {
padding: 4px 10px;
- _padding: 0;
-}
-
-#login #lost {
- margin:20px;
- font-size: 0.95em;
- float:left;
}
/* ERROR */
-
.error, #error {
margin: 0;
padding: 10px 15px;
@@ -154,18 +135,22 @@ input:focus, textarea:focus {
padding: 6px 4px 6px 35px;
}
-.input#email {
- background: #fff url(../img/admin/bg_form_email.png) no-repeat scroll 10px 8px;
-}
-.input, .input#passwd {
- background: #fff url(../img/admin/bg_form_password.png) no-repeat scroll 10px 8px;
-}
+.email_field { background: #fff url(../img/admin/bg_form_email.png) no-repeat scroll 10px 8px; }
+.password_field { background: #fff url(../img/admin/bg_form_password.png) no-repeat scroll 10px 8px; }
.button {
background: -moz-linear-gradient(center top , #F9F9F9, #E3E3E3) repeat scroll 0 0 transparent;
background: -webkit-gradient(linear, center top ,center bottom, from(#F9F9F9), to(#E3E3E3)) repeat scroll 0 0 transparent;
- border-color: #CCCCCC #BBBBBB #A0A0A0;border-left: 1px solid #BBBBBB;border-radius: 3px 3px 3px 3px;border-right: 1px solid #BBBBBB;border-style: solid;border-width: 1px;color: #000000;margin: 0; outline: medium none;padding: 3px 8px;
-
+ border-color: #CCCCCC #BBBBBB #A0A0A0;
+ border-left: 1px solid #BBBBBB;
+ border-radius: 3px 3px 3px 3px;
+ border-right: 1px solid #BBBBBB;
+ border-style: solid;
+ border-width: 1px;
+ color: #000000;
+ margin: 0;
+ outline: medium none;
+ padding: 3px 8px;
}
.button:hover {
@@ -173,10 +158,18 @@ input:focus, textarea:focus {
cursor:pointer;
}
-.center {
- font-size:20px;
- font-weight: normal;
- text-align: center;
-}
+.clear { clear: both; }
+.hide { display: none; }
+.bold { font-weight: bold; }
-#login form span { font-weight:normal;}
+.field { margin-bottom: 20px; }
+
+.fl { float: left; }
+.fr { float: right; }
+
+.no-margin { margin: 0; }
+.margin-right-5 { margin-right: 5px; }
+
+.padding-30 { padding: 30px; }
+
+.center { text-align: center; }
diff --git a/js/login.js b/js/login.js
index 33417e8aa..4b81280ed 100644
--- a/js/login.js
+++ b/js/login.js
@@ -1,11 +1,40 @@
$(document).ready(function() {
- if (document.getElementById('email')) document.getElementById('email').focus(); //$("#login").effect( "slide", { direction: "up" }, 1000 );
+ // Focus on email address field
+ $('#email').select();
+
+ // Initialize events
+ $('#login_form').submit(function(e) {
+ // Kill default behaviour
+ e.preventDefault();
+ doAjaxLogin($('#redirect').val());
+ });
+
+ $('#forgot_password_form').submit(function(e) {
+ // Kill default behaviour
+ e.preventDefault();
+ doAjaxForgot();
+ });
+
+ $('.show-forgot-password').click(function(e) {
+ // Kill default behaviour
+ e.preventDefault();
+ displayForgotPassword();
+ });
+
+ $('.show-login-form').click(function(e) {
+ // Kill default behaviour
+ e.preventDefault();
+ displayLogin();
+ });
});
+
function displayForgotPassword() {
$('#error').hide();
$('#login_form').fadeOut('fast', function () {
- $("#forgot_password").fadeIn('fast');
+ $("#forgot_password_form").fadeIn('fast');
+ // Focus on email address forgot field
+ $('#email_forgot').select();
});
}
@@ -13,8 +42,10 @@ function displayForgotPassword() {
function displayLogin() {
$('#error').hide();
- $('#forgot_password').fadeOut('fast', function () {
- $("#login_form").fadeIn('fast');
+ $('#forgot_password_form').fadeOut('fast', function () {
+ $('#login_form').fadeIn('fast');
+ // Focus on email address field
+ $('#email').select();
});
return false;
@@ -27,7 +58,7 @@ function displayLogin() {
*/
function doAjaxLogin(redirect) {
$('#error').hide();
- $('#ajax-loader').fadeIn('slow', function() {
+ $('#login_form .ajax-loader').fadeIn('slow', function() {
$.ajax({
type: "POST",
url: "ajax-tab.php",
@@ -50,16 +81,15 @@ function doAjaxLogin(redirect) {
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
- $('#error').html('
TECHNICAL ERROR:
Details: Error thrown: ' + XMLHttpRequest + '
Text status: ' + textStatus + '
');
- $('#error').fadeIn();
- $('#ajax-loader').fadeOut('slow');
+ $('#error').html('
TECHNICAL ERROR:
Details: Error thrown: ' + XMLHttpRequest + '
Text status: ' + textStatus + '
').show();
+ $('#login_form .ajax-loader').fadeOut('slow');
}
});
});
}
function doAjaxForgot() {
$('#error').hide();
- $('#ajax-loader').fadeIn('slow', function() {
+ $('#forgot_password_form .ajax-loader').fadeIn('slow', function() {
$.ajax({
type: "POST",
url: "ajax-tab.php",
@@ -73,16 +103,18 @@ function doAjaxForgot() {
email_forgot: $('#email_forgot').val()
},
success: function(jsonData) {
- if (jsonData.hasErrors) {
+ if (jsonData.hasErrors)
displayErrors(jsonData.errors);
- } else {
+ else
+ {
alert(jsonData.confirm);
+ $('#forgot_password_form .ajax-loader').hide();
+ displayLogin();
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
- $('#error').html('
TECHNICAL ERROR:
Details: Error thrown: ' + XMLHttpRequest + '
Text status: ' + textStatus + '
');
- $('#error').fadeIn();
- $('#ajax-loader').fadeOut('slow');
+ $('#error').html('
TECHNICAL ERROR:
Details: Error thrown: ' + XMLHttpRequest + '
Text status: ' + textStatus + '
').show();
+ $('#forgot_password_form .ajax-loader').fadeOut('slow');
}
});
});
@@ -91,9 +123,8 @@ function displayErrors(errors) {
str_errors = '
' + (errors.length > 1 ? there_are : there_is) + ' ' + errors.length + ' ' + (errors.length > 1 ? label_errors : label_error) + '
';
for (var error in errors) //IE6 bug fix
if (error != 'indexOf') str_errors += '- ' + errors[error] + '
';
- $('#ajax-loader').hide();
- $('#error').html(str_errors + '
');
- $('#error').fadeIn();
+ $('.ajax-loader').hide();
+ $('#error').html(str_errors + '').fadeIn('slow');
$("#login").effect("shake", {
times: 4
}, 100);