Sha256: 57e0e47d7e1d5c2a29638534598811a4bdc2a8dc5cae070d1b0f1485751e5a55
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 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 && 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gds-sso-0.7.5 | lib/gds-sso/user.rb |