Sha256: 9ec9d4c7c9fb6283f726b5f2de959df2c795ec583a8037a0169010d91a647a02
Contents?: true
Size: 1.13 KB
Versions: 2
Compression:
Stored size: 1.13 KB
Contents
require 'active_support/concern' module GDS module SSO class ApiUser def uid 0 end def name 'API User' end end module User def has_permission?(scope, permission) if permissions.has_key?(scope) permissions[scope].include?(permission) || permissions[scope].include?("admin") end end 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'] } end extend ActiveSupport::Concern module ClassMethods def find_for_gds_oauth(auth_hash) if user = self.find_by_uid(auth_hash["uid"]) user.update_attributes(GDS::SSO::User.user_params_from_auth_hash(auth_hash.to_hash), as: :oauth) user else # Create a new user. self.create!(GDS::SSO::User.user_params_from_auth_hash(auth_hash.to_hash), as: :oauth) end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gds-sso-0.7.4 | lib/gds-sso/user.rb |
gds-sso-0.7.3 | lib/gds-sso/user.rb |