Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix infinite redirect loop for user without organization and that is not superuser, nor partner #3808

Merged
merged 31 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
7b8b655
Haradd's contributions + suggested changes
lokisk1155 Jul 31, 2023
258a39a
that was weird
lokisk1155 Jul 31, 2023
42e2414
forgot 1 spec
lokisk1155 Jul 31, 2023
598daf1
last commit didn't go through
lokisk1155 Jul 31, 2023
6acf566
orginal specs were failing -> changed tests to follow recreation
lokisk1155 Jul 31, 2023
bc61c2f
linter
lokisk1155 Jul 31, 2023
589dc5d
smalllll change
lokisk1155 Aug 6, 2023
cd71ce3
Merge branch 'main' into fix-finfi-redirect-loop
lokisk1155 Aug 6, 2023
81416ef
try
lokisk1155 Aug 6, 2023
b097307
capybara wait wait wait
lokisk1155 Aug 6, 2023
c373f51
linter
lokisk1155 Aug 6, 2023
8f1f410
find body
lokisk1155 Aug 6, 2023
3a4233a
sleep
lokisk1155 Aug 6, 2023
c0f3034
linter
lokisk1155 Aug 6, 2023
de29f28
move to do before
lokisk1155 Aug 6, 2023
f19d721
and capy?
lokisk1155 Aug 6, 2023
f278ec9
sign in
lokisk1155 Aug 6, 2023
115fb63
add puts
lokisk1155 Aug 6, 2023
e068787
ignore_query: true
lokisk1155 Aug 6, 2023
025b292
puts
lokisk1155 Aug 6, 2023
b30101b
try different puts
lokisk1155 Aug 6, 2023
7c8ae9c
remove content check
lokisk1155 Aug 6, 2023
1ec1492
try url: true
lokisk1155 Aug 6, 2023
a8de688
back to og
lokisk1155 Aug 6, 2023
b83e5c3
fix tests
lokisk1155 Aug 6, 2023
2927d38
linter
lokisk1155 Aug 6, 2023
ee2d9a9
Merge branch 'main' into fix-finfi-redirect-loop
awwaiid Nov 12, 2023
7201830
fix title
lokisk1155 Nov 20, 2023
0ce6aa2
Merge branch 'fix-finfi-redirect-loop' of https://github.com/lokisk11…
lokisk1155 Nov 20, 2023
7c0953a
Merge branch 'main' into fix-finfi-redirect-loop
lokisk1155 Nov 20, 2023
0243ca4
Merge branch 'main' into fix-finfi-redirect-loop
dorner Nov 24, 2023
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
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -720,4 +720,4 @@ RUBY VERSION
ruby 3.1.2p20

BUNDLED WITH
2.4.17
2.4.18
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def dashboard_path_from_current_role
elsif current_user.organization
dashboard_path(current_user.organization)
else
root_path
"/403"
end
end

Expand Down
66 changes: 66 additions & 0 deletions public/403.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<!DOCTYPE html>
<html>
<head>
<title>The page you were looking for doesn't exist (403)</title>
lokisk1155 marked this conversation as resolved.
Show resolved Hide resolved
<meta name="viewport" content="width=device-width,initial-scale=1">
<style>
body {
background-color: #EFEFEF;
color: #2E2F30;
text-align: center;
font-family: arial, sans-serif;
margin: 0;
}

div.dialog {
width: 95%;
max-width: 33em;
margin: 4em auto 0;
}

div.dialog > div {
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #BBB;
border-top: #B00100 solid 4px;
border-top-left-radius: 9px;
border-top-right-radius: 9px;
background-color: white;
padding: 7px 12% 0;
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
}

h1 {
font-size: 100%;
color: #730E15;
line-height: 1.5em;
}

div.dialog > p {
margin: 0 0 1em;
padding: 1em;
background-color: #F7F7F7;
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #999;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-top-color: #DADADA;
color: #666;
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
}
</style>
</head>

<body>
<!-- This file lives in public/403.html -->
<div class="dialog">
<div>
<h1>The page you were looking for is forbidden.</h1>
</div>
<p>If you are the application owner check the logs for more information.</p>
</div>
</body>
</html>
15 changes: 15 additions & 0 deletions spec/requests/static_requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@
end
end

describe "Non super user without org signed in" do
let(:user_no_org) { User.create(email: "[email protected]", password: "password!") }
before do
user_no_org.add_role(:org_user)
sign_in(user_no_org)
end

describe "GET #index" do
it "redirects to a public/403.html page" do
get root_path
expect(response).to redirect_to("/403")
end
end
end

describe "Super user without org signed in" do
before do
sign_in(@super_admin_no_org)
Expand Down
12 changes: 9 additions & 3 deletions spec/system/sign_in_system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,19 @@
end

context "when users are valid and don't belong to an organization" do
it "redirects to home " do
user_no_org = create(:user, organization: nil)
let(:user_no_org) { User.create(email: '[email protected]', password: 'password!') }

before do
user_no_org.add_role(:org_user)
visit new_user_session_path

fill_in "Email", with: user_no_org.email
fill_in "Password", with: user_no_org.password
click_button "Log in"
end

expect(page).to have_current_path(root_path)
it "redirects to 403" do
expect(page).to have_current_path("/403")
end
end
end
Loading