-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhance SolidusAdmin authorization with improved redirect mechanism
In scenarios where a user attempts to access a resource, they are not authorized to access, we now handle this by redirecting them to the old admin dashboard as a fallback. This approach serves as an interim solution. As we advance in decoupling the new admin from the old one, we'll reassess and adjust this redirect method to align better with the new system's structure.
- Loading branch information
1 parent
89617d8
commit aa0a406
Showing
2 changed files
with
15 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,10 +15,22 @@ def index | |
allow_any_instance_of(SolidusAdmin::BaseController).to receive(:spree_current_user).and_return(nil) | ||
end | ||
|
||
it "redirects to unauthorized" do | ||
it "redirects to unauthorized for no user" do | ||
get :index | ||
expect(response).to redirect_to '/unauthorized' | ||
end | ||
|
||
context "with a user without update permission" do | ||
before do | ||
user = create(:user, email: '[email protected]') | ||
allow_any_instance_of(SolidusAdmin::BaseController).to receive(:spree_current_user).and_return(user) | ||
end | ||
|
||
it "redirects to unauthorized" do | ||
get :index | ||
expect(response).to redirect_to '/unauthorized' | ||
end | ||
end | ||
end | ||
|
||
context "successful request" do | ||
|