Sha256: 0ff0fda5c9e6a1e588279efdf6fe52f4352d7ad7ed8f9d1458a588fb4d2fb7cb
Contents?: true
Size: 1.25 KB
Versions: 1
Compression:
Stored size: 1.25 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 included(base) attr_accessible :uid, :email, :name, :permissions, as: :oauth end 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.6 | lib/gds-sso/user.rb |