]> git.openstreetmap.org Git - rails.git/blob - lib/oauth.rb
Add frozen_string_literal comments to ruby files
[rails.git] / lib / oauth.rb
1 # frozen_string_literal: true
2
3 module Oauth
4   SCOPES = %w[
5     read_prefs write_prefs write_diary
6     write_api write_changeset_comments read_gpx write_gpx write_notes write_redactions write_blocks
7     consume_messages send_messages openid
8   ].freeze
9   PRIVILEGED_SCOPES = %w[read_email skip_authorization].freeze
10   MODERATOR_SCOPES = %w[write_redactions write_blocks].freeze
11
12   class Scope
13     attr_reader :name
14
15     def initialize(name)
16       @name = name
17     end
18
19     def description
20       I18n.t("oauth.scopes.#{name}")
21     end
22   end
23
24   def self.scopes(privileged: false)
25     scopes = SCOPES
26     scopes += PRIVILEGED_SCOPES if privileged
27     scopes.collect { |s| Scope.new(s) }
28   end
29 end