Module: PublishingPlatform::SSO::User

Extended by:
ActiveSupport::Concern
Defined in:
lib/publishing_platform_sso/user.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.user_params_from_auth_hash(auth_hash) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/publishing_platform_sso/user.rb', line 22

def self.user_params_from_auth_hash(auth_hash)
  {
    "uid" => auth_hash["uid"],
    "email" => auth_hash["info"]["email"],
    "name" => auth_hash["info"]["name"],
    "permissions" => auth_hash["extra"]["user"]["permissions"],
    "organisation_slug" => auth_hash["extra"]["user"]["organisation_slug"],
    "organisation_content_id" => auth_hash["extra"]["user"]["organisation_content_id"],
    "disabled" => auth_hash["extra"]["user"]["disabled"],
  }
end

Instance Method Details

#has_all_permissions?(required_permissions) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
18
19
20
# File 'lib/publishing_platform_sso/user.rb', line 14

def has_all_permissions?(required_permissions)
  if permissions
    required_permissions.all? do |required_permission|
      permissions.include?(required_permission)
    end
  end
end

#has_permission?(permission) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
11
12
# File 'lib/publishing_platform_sso/user.rb', line 8

def has_permission?(permission)
  if permissions
    permissions.include?(permission)
  end
end