Sha256: 06cff9a502c5bb4f30f6f8b22768b8ca80863786674b9cb1c12714bb12be3f42

Contents?: true

Size: 662 Bytes

Versions: 5

Compression:

Stored size: 662 Bytes

Contents

require 'active_support/concern'

module GDS
  module SSO
    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

5 entries across 5 versions & 1 rubygems

Version Path
gds-sso-0.4.1 lib/gds-sso/user.rb
gds-sso-0.4.0 lib/gds-sso/user.rb
gds-sso-0.3.0 lib/gds-sso/user.rb
gds-sso-0.1.1 lib/gds-sso/user.rb
gds-sso-0.1.0 lib/gds-sso/user.rb