Sha256: 5047953bb3a11412259a4d5e4c60a878a853d5b66c91e10153dbd5c6ae46db6e
Contents?: true
Size: 976 Bytes
Versions: 3
Compression:
Stored size: 976 Bytes
Contents
require 'peoplefinder' module Peoplefinder::Concerns::Authentication extend ActiveSupport::Concern included do def self.from_auth_hash(auth_hash) email = Peoplefinder::EmailAddress.new(auth_hash['info']['email']) return unless email.valid_domain? person = Peoplefinder::Person.from_email(email) if person.new_record? person.given_name = auth_hash['info']['first_name'] person.surname = auth_hash['info']['last_name'] person.save! end person end def self.from_token(token) email = Peoplefinder::EmailAddress.new(token.user_email) person = Peoplefinder::Person.from_email(email) if person.new_record? person.given_name = email.inferred_first_name person.surname = email.inferred_last_name person.save! end person end def self.from_email(email) Peoplefinder::Person.where(email: email.to_s).first_or_initialize end end end
Version data entries
3 entries across 3 versions & 1 rubygems