Skip to content

Commit f828001

Browse files
authored
Log authentication errors (#1731)
* Log authentication errors * Adjust test
1 parent 034d6d3 commit f828001

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

app/controllers/users/omniauth_callbacks_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ def cas
77
set_cas_session
88

99
if @user.nil? && access_token&.provider == "cas"
10+
Rails.logger.warn "User from CAS with netid #{access_token&.uid} was not found. Provider: cas"
1011
redirect_to help_path
1112
flash.notice = "You can not be signed in at this time."
1213
elsif @user.nil?
14+
Rails.logger.warn "User from CAS with netid #{access_token&.uid} was not found. Provider: #{access_token&.provider}"
1315
redirect_to root_path
1416
flash.alert = "You are not a recognized CAS user."
1517
else

spec/controllers/omniauth_callbacks_controller_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
end
1414
end
1515

16-
context "uknown user" do
16+
context "unknown user" do
1717
it "redirects to the help page with alert" do
18-
controller.request.env["omniauth.auth"] = double(OmniAuth::AuthHash, provider: "cas")
18+
controller.request.env["omniauth.auth"] = double(OmniAuth::AuthHash, provider: "cas", uid: nil)
1919
allow(User).to receive(:from_cas) { nil }
2020
get :cas
2121
expect(response).to redirect_to(help_path)
@@ -25,7 +25,7 @@
2525

2626
context "non-CAS user" do
2727
it "redirects to the home page with alert" do
28-
controller.request.env["omniauth.auth"] = double(OmniAuth::AuthHash, provider: "other")
28+
controller.request.env["omniauth.auth"] = double(OmniAuth::AuthHash, provider: "other", uid: nil)
2929
allow(User).to receive(:from_cas) { nil }
3030
get :cas
3131
expect(response).to redirect_to(root_path)

0 commit comments

Comments
 (0)