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
- #clear_remotely_signed_out! ⇒ Object
- #has_permission?(permission) ⇒ Boolean
- #included(base) ⇒ Object
- #set_remotely_signed_out! ⇒ Object
Class Method Details
.user_params_from_auth_hash(auth_hash) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/gds-sso/user.rb', line 44 def self.user_params_from_auth_hash(auth_hash) if auth_hash['extra']['user']['permissions'].is_a?(Hash) # Until Signon emits an array of permissions, we need to support legacy Hash. # Once Signon has been changed, we can drop support for Hash. = auth_hash['extra']['user']['permissions'].values.first else = auth_hash['extra']['user']['permissions'] end { 'uid' => auth_hash['uid'], 'email' => auth_hash['info']['email'], 'name' => auth_hash['info']['name'], 'permissions' => } end |
Instance Method Details
#clear_remotely_signed_out! ⇒ Object
60 61 62 |
# File 'lib/gds-sso/user.rb', line 60 def clear_remotely_signed_out! self.update_attribute(:remotely_signed_out, false) end |
#has_permission?(permission) ⇒ Boolean
34 35 36 37 38 39 40 41 42 |
# File 'lib/gds-sso/user.rb', line 34 def () if if .is_a?(Hash) raise "GDS::SSO no longer supports a Hash for permissions. Array expected. Maybe you need to migrate?" end .include?() end end |
#included(base) ⇒ Object
30 31 32 |
# File 'lib/gds-sso/user.rb', line 30 def included(base) attr_accessible :uid, :email, :name, :permissions, as: :oauth end |
#set_remotely_signed_out! ⇒ Object
64 65 66 |
# File 'lib/gds-sso/user.rb', line 64 def set_remotely_signed_out! self.update_attribute(:remotely_signed_out, true) end |