FEATURE: add setting permanent_session_cookie to configure session stickiness

Now admins can turn make the login cookie die after the browser is closed, so the user needs to log in everytime.
This commit is contained in:
Rafael dos Santos Silva
2016-05-17 01:12:09 -03:00
parent dd0260e435
commit 09ef5f613e
3 changed files with 7 additions and 1 deletions

View File

@ -66,7 +66,11 @@ class Auth::DefaultCurrentUserProvider
user.auth_token = SecureRandom.hex(16)
user.save!
end
cookies.permanent[TOKEN_COOKIE] = { value: user.auth_token, httponly: true }
if SiteSetting.permanent_session_cookie
cookies.permanent[TOKEN_COOKIE] = { value: user.auth_token, httponly: true }
else
cookies[TOKEN_COOKIE] = { value: user.auth_token, httponly: true }
end
make_developer_admin(user)
enable_bootstrap_mode(user)
@env[CURRENT_USER_KEY] = user