Skip to content

Commit fbb856f

Browse files
authored
fix infinite redirect by clean up expired session
1 parent 518e14c commit fbb856f

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed
Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
module RedmineOpenidConnect
22
module ApplicationControllerPatch
33
def require_login
4-
return super unless (OicSession.enabled? && !OicSession.login_selector?)
5-
6-
if !User.current.logged?
4+
if !User.current.logged? && OicSession.enabled? && OicSession.login_selector?
75
if request.get?
86
url = request.original_url
97
else
108
url = url_for(:controller => params[:controller], :action => params[:action], :id => params[:id], :project_id => params[:project_id])
119
end
10+
# this should fix infinite redirect
11+
# because this plugin not reseting session when assigning logged user
12+
# it should at least reset session when expired so it will not check every time
13+
# which will cause infinite redirect
14+
# also clean lingering oic sessio so that back_url still works
15+
reset_session
1216
session[:remember_url] = url
17+
end
18+
return super unless (OicSession.enabled? && !OicSession.login_selector?)
19+
20+
if !User.current.logged?
1321
redirect_to oic_login_url
1422
return false
1523
end
@@ -18,7 +26,8 @@ def require_login
1826

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

2332
if user && user.is_a?(User)
2433
User.current = user
@@ -29,3 +38,4 @@ def logged_user=(user)
2938
end
3039
end # ApplicationControllerPatch
3140
end
41+

0 commit comments

Comments
 (0)