-
-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: apply `show` policy on `click_row_to_view_record` * simplify
- Loading branch information
Showing
3 changed files
with
23 additions
and
10 deletions.
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
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module Avo | ||
module Concerns | ||
module ChecksShowAuthorization | ||
include Avo::Concerns::ChecksAssocAuthorization | ||
|
||
extend ActiveSupport::Concern | ||
|
||
def can_view? | ||
return false if Avo.configuration.resource_default_view.edit? | ||
|
||
return authorize_association_for(:show) if @reflection.present? | ||
|
||
# Even if there's a @reflection object present, for show we're going to fallback to the original policy. | ||
@resource.authorization.authorize_action(:show, raise_exception: false) | ||
end | ||
end | ||
end | ||
end |