Enable configuration of backend login session persistence (#2924)

Thanks to @ChVuagniaux. Fixes #2394
This commit is contained in:
Christophe Vuagniaux 2017-06-22 22:34:16 +02:00 committed by Luke Towers
parent f8d9667f0e
commit e3a567cb78
7 changed files with 47 additions and 1 deletions

View File

@ -51,6 +51,24 @@ return [
'backendForceSecure' => null,
/*
|--------------------------------------------------------------------------
| Back-end login remember
|--------------------------------------------------------------------------
|
| Define live duration of backend sessions :
|
| true - session never expire (cookie expiration in 5 years)
|
| false - session have a limited time (see session.lifetime)
|
| null - The form login display a checkbox that allow user to choose
| wanted behavior
|
*/
'backendForceRemember' => true,
/*
|--------------------------------------------------------------------------
| Back-end timezone

View File

@ -819,6 +819,7 @@ body.outer .layout > .layout-row > .layout-cell .outer-form-container h2{font-si
body.outer .layout > .layout-row > .layout-cell .outer-form-container .horizontal-form{font-size:0;display:-webkit-box;display:-webkit-flex;display:-moz-flex;display:-ms-flexbox;display:-ms-flex;display:flex}
body.outer .layout > .layout-row > .layout-cell .outer-form-container .horizontal-form input{vertical-align:top;margin-right:9px;display:inline-block;border:none;-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px}
body.outer .layout > .layout-row > .layout-cell .outer-form-container .horizontal-form button{background:#0181b9;text-align:center;font-size:13px;font-weight:600;height:40px;vertical-align:top;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}
body.outer .layout > .layout-row > .layout-cell .outer-form-container .remember label {color:rgba(255,255,255,0.44)}
body.outer .layout > .layout-row > .layout-cell .outer-form-container .forgot-password{margin-top:30px;font-size:13px;top:8px}
body.outer .layout > .layout-row > .layout-cell .outer-form-container .forgot-password a{color:rgba(255,255,255,0.44)}
body.outer .layout > .layout-row > .layout-cell .outer-form-container .forgot-password:before{color:rgba(255,255,255,0.44);font-size:14px;position:relative;margin-right:5px}

View File

@ -74,6 +74,12 @@ body.outer {
}
}
.remember {
label {
color: @color-outer-muted-text;
}
}
.forgot-password {
margin-top: 30px;
font-size: 13px;

View File

@ -69,11 +69,15 @@ class Auth extends Controller
throw new ValidationException($validation);
}
if (is_null($remember = config('cms.backendForceRemember', true))) {
$remember = (bool) post('remember');
}
// Authenticate user
$user = BackendAuth::authenticate([
'login' => post('login'),
'password' => post('password')
], true);
], $remember);
// Load version updates
UpdateManager::instance()->update();

View File

@ -32,6 +32,21 @@
</button>
</div>
<?php if (is_null(config('cms.backendForceRemember', true))) : ?>
<!-- Remember checkbox -->
<div class="form-group checkbox-field horizontal-form remember">
<div class="checkbox custom-checkbox">
<input
type="checkbox"
id="remember"
name="remember" />
<label for="remember">
<?= e(trans('backend::lang.account.remember_me')) ?>
</label>
</div>
</div>
<?php endif; ?>
<p class="oc-icon-lock pull-right forgot-password">
<!-- Forgot your password? -->
<a href="<?= Backend::url('backend/auth/restore') ?>" class="text-muted">

View File

@ -39,6 +39,7 @@ return [
'restore' => 'Restore',
'login_placeholder' => 'login',
'password_placeholder' => 'password',
'remember_me' => 'Stay logged in',
'forgot_password' => 'Forgot your password?',
'enter_email' => 'Enter your email',
'enter_login' => 'Enter your login',

View File

@ -39,6 +39,7 @@ return [
'restore' => 'Restaurer',
'login_placeholder' => 'identifiant',
'password_placeholder' => 'mot de passe',
'remember_me' => 'Rester connecté',
'forgot_password' => 'Mot de passe oublié ?',
'enter_email' => 'Saisir votre adresse e-mail',
'enter_login' => 'Saisir votre identifiant',