[*] BO: Add an option to autologout to the backoffice after 15 minutes

This commit is contained in:
Rémi Gaillard
2013-10-10 12:20:10 +02:00
parent 6c35b20b02
commit 278dc32482
4 changed files with 16 additions and 7 deletions
@@ -85,12 +85,8 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="checkbox"> <div class="checkbox">
<label for="stayloggedin"> <label for="stay_logged_in">
<input <input name="stay_logged_in" type="checkbox" id="stay_logged_in" value="1" />
name="stayloggedin"
type="checkbox"
id="stayloggedin"
/>
{l s='Keep me logged in'} {l s='Keep me logged in'}
</label> </label>
</div> </div>
+8
View File
@@ -1999,6 +1999,14 @@ class AdminControllerCore extends Controller
if (isset($_GET['logout'])) if (isset($_GET['logout']))
$this->context->employee->logout(); $this->context->employee->logout();
if (isset(Context::getContext()->cookie->last_activity))
{
if ($this->context->cookie->last_activity + 900 < time())
$this->context->employee->logout();
else
$this->context->cookie->last_activity = time();
}
if ($this->controller_name != 'AdminLogin' && (!isset($this->context->employee) || !$this->context->employee->isLoggedBack())) if ($this->controller_name != 'AdminLogin' && (!isset($this->context->employee) || !$this->context->employee->isLoggedBack()))
{ {
if (isset($this->context->employee)) if (isset($this->context->employee))
@@ -180,6 +180,10 @@ class AdminLoginControllerCore extends AdminController
$cookie->profile = $this->context->employee->id_profile; $cookie->profile = $this->context->employee->id_profile;
$cookie->passwd = $this->context->employee->passwd; $cookie->passwd = $this->context->employee->passwd;
$cookie->remote_addr = $this->context->employee->remote_addr; $cookie->remote_addr = $this->context->employee->remote_addr;
if (!Tools::getValue('stay_logged_in'))
$cookie->last_activity = time();
$cookie->write(); $cookie->write();
// If there is a valid controller name submitted, redirect to it // If there is a valid controller name submitted, redirect to it
+2 -1
View File
@@ -94,7 +94,8 @@ function doAjaxLogin(redirect) {
submitLogin: "1", submitLogin: "1",
passwd: $('#passwd').val(), passwd: $('#passwd').val(),
email: $('#email').val(), email: $('#email').val(),
redirect: redirect redirect: redirect,
stay_logged_in: $('#stay_logged_in:checked').val()
}, },
success: function(jsonData) { success: function(jsonData) {
if (jsonData.hasErrors) if (jsonData.hasErrors)