Module: GDS::SSO::User
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/gds-sso/user.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #anonymous_user_id ⇒ Object
- #clear_remotely_signed_out! ⇒ Object
- #has_all_permissions?(required_permissions) ⇒ Boolean
- #has_permission?(permission) ⇒ Boolean
- #set_remotely_signed_out! ⇒ Object
Class Method Details
.user_params_from_auth_hash(auth_hash) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/gds-sso/user.rb', line 23 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
#anonymous_user_id ⇒ Object
43 44 45 46 47 48 |
# File 'lib/gds-sso/user.rb', line 43 def anonymous_user_id secret = ENV["ANONYMOUS_USER_ID_SECRET"] return if secret.nil? @anonymous_user_id ||= Digest::SHA2.hexdigest(JSON.dump([uid, secret]))[..16] end |
#clear_remotely_signed_out! ⇒ Object
35 36 37 |
# File 'lib/gds-sso/user.rb', line 35 def clear_remotely_signed_out! update_attribute(:remotely_signed_out, false) end |
#has_all_permissions?(required_permissions) ⇒ Boolean
15 16 17 18 19 20 21 |
# File 'lib/gds-sso/user.rb', line 15 def () if .all? do || .include?() end end end |
#has_permission?(permission) ⇒ Boolean
9 10 11 12 13 |
# File 'lib/gds-sso/user.rb', line 9 def () if .include?() end end |
#set_remotely_signed_out! ⇒ Object
39 40 41 |
# File 'lib/gds-sso/user.rb', line 39 def set_remotely_signed_out! update_attribute(:remotely_signed_out, true) end |