File tree 1 file changed +14
-2
lines changed
lib/casclient/frameworks/rails
1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -110,7 +110,7 @@ def filter(controller)
110
110
return true
111
111
else
112
112
log . warn ( "Ticket #{ st . ticket . inspect } failed validation -- #{ vr . failure_code } : #{ vr . failure_message } " )
113
- redirect_to_cas_for_authentication ( controller )
113
+ unauthorized! ( controller , vr )
114
114
return false
115
115
end
116
116
else # no service ticket was present in the request
@@ -128,7 +128,7 @@ def filter(controller)
128
128
end
129
129
end
130
130
131
- redirect_to_cas_for_authentication ( controller )
131
+ unauthorized! ( controller )
132
132
return false
133
133
end
134
134
end
@@ -181,6 +181,18 @@ def logout(controller, service = nil)
181
181
controller . send ( :redirect_to , client . logout_url ( referer ) )
182
182
end
183
183
184
+ def unauthorized! ( controller , vr = nil )
185
+ if controller . params [ :format ] == "xml"
186
+ if vr
187
+ controller . send ( :render , :xml => "<errors><error>#{ vr . failure_message } </error></errors>" , :status => 401 )
188
+ else
189
+ controller . send ( :head , 401 )
190
+ end
191
+ else
192
+ redirect_to_cas_for_authentication ( controller )
193
+ end
194
+ end
195
+
184
196
def redirect_to_cas_for_authentication ( controller )
185
197
redirect_url = login_url ( controller )
186
198
You can’t perform that action at this time.
0 commit comments