Modify admin layout to only manage tenants and admins

We only want to render the account link and login items in the header.
And we want only render the Multitenancy and Administrators sections in
the admin sidebar.

We include the administrators management so it's possible to give
permissions to other users to manage tenants.

In order to restrict access to other sections by typing the URL or
following a link, we're only enabling the rest of the routes when we
aren't in the multitenancy management mode.
This commit is contained in:
taitus
2022-12-23 12:13:35 +01:00
parent 1e6901ec34
commit a5911f5c6a
24 changed files with 535 additions and 360 deletions

View File

@@ -69,4 +69,22 @@ describe Users::SessionsController do
end
end
end
describe "after_sign_in_path_for" do
it "redirects to account path when multitenancy_management_mode is enabled and user is not an admin" do
allow(Rails.application.config).to receive(:multitenancy_management_mode).and_return(true)
post :create, params: { user: { login: "citizen@consul.org", password: "12345678" }}
expect(response).to redirect_to account_path
end
it "redirects to welcome path when multitenancy_management_mode is disabled" do
allow(Rails.application.config).to receive(:multitenancy_management_mode).and_return(false)
post :create, params: { user: { login: "citizen@consul.org", password: "12345678" }}
expect(response).to redirect_to welcome_path
end
end
end