Sha256: dcebbb432f690a6f623219f5c6d43fe5fbfc76ed19b8e772162f712e3b338138

Contents?: true

Size: 768 Bytes

Versions: 7

Compression:

Stored size: 768 Bytes

Contents

require 'active_support/concern'

module GDS
  module SSO
    class ApiUser
      def uid
        0
      end

      def name
        'API User'
      end
    end

    module User
      def self.user_params_from_auth_hash(auth_hash)
        {'uid' => auth_hash['uid'], 'email' => auth_hash['user_info']['email'], 'name' => auth_hash['user_info']['name'], 'version' => auth_hash['extra']['user_hash']['version']}
      end

      extend ActiveSupport::Concern

      module ClassMethods
        def find_for_gds_oauth(auth_hash)
          if user = self.find_by_uid(auth_hash["uid"])
            user
          else # Create a new user.
            self.create!(GDS::SSO::User.user_params_from_auth_hash(auth_hash))
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
gds-sso-0.5.4 lib/gds-sso/user.rb
gds-sso-0.5.3 lib/gds-sso/user.rb
gds-sso-0.5.2 lib/gds-sso/user.rb
gds-sso-0.5.1 lib/gds-sso/user.rb
gds-sso-0.5.0 lib/gds-sso/user.rb
gds-sso-0.4.3 lib/gds-sso/user.rb
gds-sso-0.4.2 lib/gds-sso/user.rb