[*] BO: Add an option to autologout to the backoffice after 15 minutes
This commit is contained in:
@@ -85,12 +85,8 @@
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="checkbox">
|
||||
<label for="stayloggedin">
|
||||
<input
|
||||
name="stayloggedin"
|
||||
type="checkbox"
|
||||
id="stayloggedin"
|
||||
/>
|
||||
<label for="stay_logged_in">
|
||||
<input name="stay_logged_in" type="checkbox" id="stay_logged_in" value="1" />
|
||||
{l s='Keep me logged in'}
|
||||
</label>
|
||||
</div>
|
||||
|
||||
@@ -1998,6 +1998,14 @@ class AdminControllerCore extends Controller
|
||||
|
||||
if (isset($_GET['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()))
|
||||
{
|
||||
|
||||
@@ -180,6 +180,10 @@ class AdminLoginControllerCore extends AdminController
|
||||
$cookie->profile = $this->context->employee->id_profile;
|
||||
$cookie->passwd = $this->context->employee->passwd;
|
||||
$cookie->remote_addr = $this->context->employee->remote_addr;
|
||||
|
||||
if (!Tools::getValue('stay_logged_in'))
|
||||
$cookie->last_activity = time();
|
||||
|
||||
$cookie->write();
|
||||
|
||||
// If there is a valid controller name submitted, redirect to it
|
||||
|
||||
+2
-1
@@ -94,7 +94,8 @@ function doAjaxLogin(redirect) {
|
||||
submitLogin: "1",
|
||||
passwd: $('#passwd').val(),
|
||||
email: $('#email').val(),
|
||||
redirect: redirect
|
||||
redirect: redirect,
|
||||
stay_logged_in: $('#stay_logged_in:checked').val()
|
||||
},
|
||||
success: function(jsonData) {
|
||||
if (jsonData.hasErrors)
|
||||
|
||||
Reference in New Issue
Block a user