You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Wire in authorization checks into administrate, following the guide. Unfortunately, the app/views/fields/belongs_to/_show.html.erb template for belongs_to does not leverage #show_action? to determine if the link should be rendered:
<% if valid_action?(:show, field.associated_class) %>
<%= link_to(
field.display_associated_resource,
[namespace, field.data],
) %>
<% else %>
<%= field.display_associated_resource %>
<% end %>
<% end %>
It checks #valid_action? to see if the action for the resource is "valid", which I interpret as meaning: is the action supported. However, the template does not also check #show_action? prior to rendering the link.
Compare that with how app/views/administrate/application/_collection.html.erb uses both #valid_action? and #show_action? to determine if a link should be rendered.
Thank you @carlost. Yeah, there are a few places where this happens, and I'm currently working on something to fix it more cleanly (#1941). Having said that, my changes may still take a while to come, so perhaps you could create a PR that fixes it for BelongsTo for the time being?
Wire in authorization checks into administrate, following the guide. Unfortunately, the
app/views/fields/belongs_to/_show.html.erb
template forbelongs_to
does not leverage#show_action?
to determine if the link should be rendered:administrate/app/views/fields/belongs_to/_show.html.erb
Lines 18 to 27 in e1baea3
It checks
#valid_action?
to see if the action for the resource is "valid", which I interpret as meaning: is the action supported. However, the template does not also check#show_action?
prior to rendering the link.Compare that with how
app/views/administrate/application/_collection.html.erb
uses both#valid_action?
and#show_action?
to determine if a link should be rendered.administrate/app/views/administrate/application/_collection.html.erb
Lines 77 to 83 in e1baea3
Administrate is generated links to actions that user's are not authorized to follow. If users see a link ... they will click a link.
Is this behavior by design? Should i be overriding both valid_action? and show_action? to handle authorization?
The text was updated successfully, but these errors were encountered: