sign_out user after 7 days [fixes SCI-2323]

This commit is contained in:
zmagod 2018-04-24 15:42:31 +02:00
parent 1e4a975304
commit 796e7c9822

View file

@ -6,6 +6,7 @@ class ApplicationController < ActionController::Base
# For APIs, you may want to use :null_session instead. # For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception, prepend: true protect_from_forgery with: :exception, prepend: true
before_action :authenticate_user! before_action :authenticate_user!
before_action :check_max_session_time
helper_method :current_team helper_method :current_team
before_action :update_current_team, if: :user_signed_in? before_action :update_current_team, if: :user_signed_in?
around_action :set_time_zone, if: :current_user around_action :set_time_zone, if: :current_user
@ -65,6 +66,13 @@ class ApplicationController < ActionController::Base
private private
def check_max_session_time
if current_user && current_user.current_sign_in_at + 7.days < Time.now
sign_out current_user
redirect_to new_user_session_path
end
end
def update_current_team def update_current_team
if current_user.current_team_id.blank? && if current_user.current_team_id.blank? &&
current_user.teams.count > 0 current_user.teams.count > 0