Highlight moderator-only scopes when showing authorizations

This commit is contained in:
Anton Khorev 2023-10-21 20:39:55 +03:00
parent a7ba87340d
commit fb1ebf8925
5 changed files with 17 additions and 3 deletions

View file

@ -0,0 +1,13 @@
module AuthorizationHelper
include ActionView::Helpers::TranslationHelper
def authorization_scope(scope)
html = []
html << t("oauth.scopes.#{scope}")
if Oauth::MODERATOR_SCOPES.include? scope
html << " "
html << image_tag("roles/moderator.png", :srcset => image_path("roles/moderator.svg", :class => "align-text-bottom"), :size => "20x20")
end
safe_join(html)
end
end

View file

@ -10,7 +10,7 @@
<td class="align-middle">
<ul class="list-unstyled mb-0">
<% application.scopes.each do |scope| -%>
<li><%= t "oauth.scopes.#{scope}" %> <code class="text-muted">(<%= scope %>)</code></li>
<li><%= authorization_scope(scope) %> <code class="text-muted">(<%= scope %>)</code></li>
<% end -%>
</ul>
</td>

View file

@ -6,7 +6,7 @@
<ul>
<% @pre_auth.scopes.each do |scope| -%>
<li><%= t "oauth.scopes.#{scope}" %></li>
<li><%= authorization_scope(scope) %></li>
<% end -%>
</ul>

View file

@ -5,7 +5,7 @@
<td class="align-middle">
<ul class="list-unstyled mb-0">
<% application.authorized_scopes_for(current_user).each do |scope| -%>
<li><%= t "oauth.scopes.#{scope}" %></li>
<li><%= authorization_scope(scope) %></li>
<% end -%>
</ul>
</td>

View file

@ -1,6 +1,7 @@
module Oauth
SCOPES = %w[read_prefs write_prefs write_diary write_api read_gpx write_gpx write_notes].freeze
PRIVILEGED_SCOPES = %w[read_email skip_authorization].freeze
MODERATOR_SCOPES = %w[].freeze
OAUTH2_SCOPES = %w[openid].freeze
class Scope