Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions lib/redmine_openid_connect/application_controller_patch.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
module RedmineOpenidConnect
module ApplicationControllerPatch
def require_login
return super unless (OicSession.enabled? && !OicSession.login_selector?)

if !User.current.logged?
if !User.current.logged? && OicSession.enabled?
if request.get?
url = request.original_url
else
url = url_for(:controller => params[:controller], :action => params[:action], :id => params[:id], :project_id => params[:project_id])
end
# this should fix infinite redirect
# because this plugin not reseting session when assigning logged user
# it should at least reset session when expired so it will not check every time
# which will cause infinite redirect
# also clean lingering oic sessio so that back_url still works
reset_session
session[:remember_url] = url
end
return super unless (OicSession.enabled? && !OicSession.login_selector?)

if !User.current.logged?
redirect_to oic_login_url
return false
end
Expand All @@ -18,7 +26,8 @@ def require_login

# set the current user _without_ resetting the session first
def logged_user=(user)
return super(user) unless OicSession.enabled?
# only override parent if the request is from ioc user
return super(user) unless session[:oic_session_id]

if user && user.is_a?(User)
User.current = user
Expand All @@ -29,3 +38,4 @@ def logged_user=(user)
end
end # ApplicationControllerPatch
end