From: Anton Khorev Date: Sat, 21 Oct 2023 17:39:55 +0000 (+0300) Subject: Highlight moderator-only scopes when showing authorizations X-Git-Tag: live~873^2~2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/fb1ebf89251313f535e52308d0df0c06da93f1c7 Highlight moderator-only scopes when showing authorizations --- diff --git a/app/helpers/authorization_helper.rb b/app/helpers/authorization_helper.rb new file mode 100644 index 000000000..11c8c298f --- /dev/null +++ b/app/helpers/authorization_helper.rb @@ -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 diff --git a/app/views/oauth2_applications/_application.html.erb b/app/views/oauth2_applications/_application.html.erb index 564fa81eb..57e852182 100644 --- a/app/views/oauth2_applications/_application.html.erb +++ b/app/views/oauth2_applications/_application.html.erb @@ -10,7 +10,7 @@ diff --git a/app/views/oauth2_authorizations/new.html.erb b/app/views/oauth2_authorizations/new.html.erb index ac9c7c6c5..8720bf05a 100644 --- a/app/views/oauth2_authorizations/new.html.erb +++ b/app/views/oauth2_authorizations/new.html.erb @@ -6,7 +6,7 @@ diff --git a/app/views/oauth2_authorized_applications/_application.html.erb b/app/views/oauth2_authorized_applications/_application.html.erb index 8abbb26ed..28d048c4a 100644 --- a/app/views/oauth2_authorized_applications/_application.html.erb +++ b/app/views/oauth2_authorized_applications/_application.html.erb @@ -5,7 +5,7 @@ diff --git a/lib/oauth.rb b/lib/oauth.rb index 0456c0873..e5642163d 100644 --- a/lib/oauth.rb +++ b/lib/oauth.rb @@ -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