mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 15:20:13 +01:00
Move the expire_session route
It's now in the cucumber login helper.
This commit is contained in:
parent
2c5aff3b36
commit
931791edfd
3 changed files with 9 additions and 24 deletions
|
|
@ -47,29 +47,6 @@ class LoginController < ApplicationController
|
||||||
logout_user
|
logout_user
|
||||||
end
|
end
|
||||||
|
|
||||||
def expire_session
|
|
||||||
# this is a hack to enable cucumber to expire a session by calling this
|
|
||||||
# method. The method will be unavailable for production environment
|
|
||||||
|
|
||||||
@user.forget_me if logged_in?
|
|
||||||
cookies.delete :auth_token
|
|
||||||
session['user_id'] = nil
|
|
||||||
reset_session
|
|
||||||
|
|
||||||
unless Rails.env.production?
|
|
||||||
session['expiry_time'] = Time.now
|
|
||||||
respond_to do |format|
|
|
||||||
format.html { render :text => "Session expired for test purposes"}
|
|
||||||
format.js { render :text => "" }
|
|
||||||
end
|
|
||||||
else
|
|
||||||
respond_to do |format|
|
|
||||||
format.html { render :text => "Not available for production use"}
|
|
||||||
format.js { render :text => "" }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def check_expiry
|
def check_expiry
|
||||||
# Gets called by periodically_call_remote to check whether
|
# Gets called by periodically_call_remote to check whether
|
||||||
# the session has timed out yet
|
# the session has timed out yet
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ Tracksapp::Application.routes.draw do
|
||||||
root :to => 'todos#index'
|
root :to => 'todos#index'
|
||||||
|
|
||||||
match 'login' => 'login#login'
|
match 'login' => 'login#login'
|
||||||
match 'login/expire_session' => 'login#expire_session'
|
|
||||||
match 'login/check_expiry' => 'login#check_expiry'
|
match 'login/check_expiry' => 'login#check_expiry'
|
||||||
match 'logout' => 'login#logout'
|
match 'logout' => 'login#logout'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,14 @@ class SessionBackdoorController < ::ApplicationController
|
||||||
cookies[:auth_token] = { :value => user.remember_token, :expires => user.remember_token_expires_at }
|
cookies[:auth_token] = { :value => user.remember_token, :expires => user.remember_token_expires_at }
|
||||||
redirect_to root_path
|
redirect_to root_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def expire_session
|
||||||
|
current_user.forget_me if logged_in?
|
||||||
|
cookies.delete :auth_token
|
||||||
|
session['user_id'] = nil
|
||||||
|
reset_session
|
||||||
|
session['expiry_time'] = Time.now
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
module TracksLoginHelper
|
module TracksLoginHelper
|
||||||
|
|
@ -20,6 +28,7 @@ module TracksLoginHelper
|
||||||
_routes.draw do
|
_routes.draw do
|
||||||
# here you can add any route you want
|
# here you can add any route you want
|
||||||
match "/test_login_backdoor", to: "session_backdoor#create"
|
match "/test_login_backdoor", to: "session_backdoor#create"
|
||||||
|
match "login/expire_session", to: "session_backdoor#expire_session"
|
||||||
end
|
end
|
||||||
ActiveSupport.on_load(:action_controller) { _routes.finalize! }
|
ActiveSupport.on_load(:action_controller) { _routes.finalize! }
|
||||||
ensure
|
ensure
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue