Sha256: f815ce03b89f62a4f20157dd53b5d53d35feb5fd9eaa72b7fb27168fdba6ee72

Contents?: true

Size: 701 Bytes

Versions: 2

Compression:

Stored size: 701 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['info']['email'], 'name' => auth_hash['info']['name']}
      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

2 entries across 2 versions & 1 rubygems

Version Path
gds-sso-0.6.1 lib/gds-sso/user.rb
gds-sso-0.6.0 lib/gds-sso/user.rb