[opf1054] Implements configurable session_lifetime

- added locales also for the settings
pull/225/head
Christian Ratz 11 years ago
parent cc8cc80da2
commit f06e6f9ed7
  1. 21
      app/controllers/application_controller.rb
  2. 3
      config/locales/de.yml
  3. 3
      config/locales/en.yml

@ -62,7 +62,7 @@ class ApplicationController < ActionController::Base
end
end
before_filter :user_setup, :check_if_login_required, :reset_i18n_fallbacks, :set_localization
before_filter :user_setup, :check_if_login_required, :reset_i18n_fallbacks, :set_localization, :check_session_lifetime
rescue_from ActionController::InvalidAuthenticityToken, :with => :invalid_authenticity_token
@ -591,6 +591,25 @@ class ApplicationController < ActionController::Base
end
ActiveSupport.run_load_hooks(:application_controller, self)
def check_session_lifetime
if Setting.session_ttl_enabled?
session_ttl_sec = Setting.session_ttl.to_i * 60
if session[:updated_at] && User.current.logged? && ((session[:updated_at] + session_ttl_sec) < Time.now)
self.logged_user = nil
if request.get?
url = url_for(params)
else
url = url_for(:controller => params[:controller], :action => params[:action], :id => params[:id], :project_id => params[:project_id])
end
flash[:warning] = I18n.t('notice_forced_logout', :ttl_time => Setting.session_ttl)
redirect_to(:controller => "account", :action => "login", :back_url => url)
else
session[:updated_at] = Time.now
end
end
end
private
def permitted_params

@ -993,6 +993,7 @@ de:
notice_failed_to_save_members: "Benutzer konnte nicht gespeichert werden: %{errors}."
notice_feeds_access_key_reseted: "Ihr Atom-Zugriffsschlüssel wurde zurückgesetzt."
notice_file_not_found: "Anhang existiert nicht oder ist gelöscht worden."
notice_forced_logout: "Nach %{ttl_time} Minuten Inaktivität wurden Sie automatisch ausgeloggt."
notice_internal_server_error: "Auf der von Ihnen aufgerufenen Seite ist ein Fehler aufgetreten. Kontaktieren Sie bitte ihren %{app_title} Administrator wenn sie wiederholt Probleme mit dem Aufrufen der Seite haben."
notice_issue_done_ratios_updated: "Der Ticket-Fortschritt wurde aktualisiert."
notice_locking_conflict: "Die Informationen wurde zwischenzeitlich von einem anderen Benutzer geändert."
@ -1186,6 +1187,8 @@ de:
setting_rest_api_enabled: "REST-Schnittstelle aktivieren"
setting_self_registration: "Anmeldung ermöglicht"
setting_sequential_project_identifiers: "Fortlaufende Projektkennungen generieren"
setting_session_ttl: "Session Ablaufzeit"
setting_session_ttl_enabled: "Session läuft ab"
setting_start_of_week: "Wochenanfang"
setting_sys_api_enabled: "Webservice zur Verwaltung der Projektarchive benutzen"
setting_text_formatting: "Textformatierung"

@ -982,6 +982,7 @@ en:
notice_failed_to_save_members: "Failed to save member(s): %{errors}."
notice_feeds_access_key_reseted: "Your RSS access key was reset."
notice_file_not_found: "The page you were trying to access doesn't exist or has been removed."
notice_forced_logout: "You have been automatically logged out after %{ttl_time} minutes of inactivity."
notice_internal_server_error: "An error occurred on the page you were trying to access. If you continue to experience problems please contact your %{app_title} administrator for assistance."
notice_issue_done_ratios_updated: "Issue done ratios updated."
notice_locking_conflict: "Information has been updated by at least one other user in the meantime."
@ -1169,6 +1170,8 @@ en:
setting_rest_api_enabled: "Enable REST web service"
setting_self_registration: "Self-registration"
setting_sequential_project_identifiers: "Generate sequential project identifiers"
setting_session_ttl: "Session expiry time"
setting_session_ttl_enabled: "Session expires"
setting_start_of_week: "Start calendars on"
setting_sys_api_enabled: "Enable WS for repository management"
setting_text_formatting: "Text formatting"

Loading…
Cancel
Save