X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/34e3e51456774127d43408b7ab65c24f41373f62..b704f59769f605bcdc7e4c4a5d0e2f668464aae9:/lib/session_persistence.rb?ds=sidebyside diff --git a/lib/session_persistence.rb b/lib/session_persistence.rb index 2244a3e63..0a9f1d2f1 100644 --- a/lib/session_persistence.rb +++ b/lib/session_persistence.rb @@ -20,13 +20,18 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. module SessionPersistence - private + class << self + private - # Install filter when we are included - def self.included(controller) - controller.after_filter :persist_session + # Install filter when we are included + def included(controller) + super + controller.after_action :persist_session + end end + private + # Override this method if you don't want to use session[:_remember_for]. def session_persistence_key :_remember_for @@ -37,7 +42,7 @@ module SessionPersistence # session_expires_after 1.hour # session_expires_after 2.weeks def session_expires_after(seconds) - session[session_persistence_key] = seconds + session[session_persistence_key] = seconds.to_i end # Expire the session. @@ -48,10 +53,8 @@ module SessionPersistence # Filter callback def persist_session - if session[session_persistence_key] - request.session_options[:expire_after] = session[session_persistence_key] - end - rescue + request.session_options[:expire_after] = session[session_persistence_key] if session[session_persistence_key] + rescue StandardError reset_session end end