Class: Omniauth::Rails::AuthorizationChecker

Inherits:
Object
  • Object
show all
Defined in:
app/models/omniauth/rails/authorization_checker.rb

Constant Summary collapse

AUTHORIZATION_TYPES =
{
  domains: AuthorizationTypes::Domains,
  emails: AuthorizationTypes::Emails,
  regex: AuthorizationTypes::Regex,
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(email:, params:) ⇒ AuthorizationChecker

Returns a new instance of AuthorizationChecker.



11
12
13
14
# File 'app/models/omniauth/rails/authorization_checker.rb', line 11

def initialize(email:, params:)
  @email = email
  @params = params
end

Instance Method Details

#authorized?Boolean

Returns:

  • (Boolean)


16
17
18
19
20
21
# File 'app/models/omniauth/rails/authorization_checker.rb', line 16

def authorized?
  params.map do |key, value|
    raise "Invalid key for authorization constraint" unless AUTHORIZATION_TYPES.key?(key)
    AUTHORIZATION_TYPES[key].new(email: email, value: value).authorized?
  end.all?
end