Skip to content

Instantly share code, notes, and snippets.

@b-murphy
Last active December 11, 2015 07:08
Show Gist options
  • Save b-murphy/4564165 to your computer and use it in GitHub Desktop.
Save b-murphy/4564165 to your computer and use it in GitHub Desktop.
require 'virtus'
class Authenticator
# Required for Errors & Messages
##########################################
include Virtus
extend ActiveModel::Naming
include ActiveModel::Conversion
include ActiveModel::Validations
def persisted?
false
end
validate_the_presence_of :invite, message: "Sorry, we couldn't find your invite. Please follow the link from your invite email."
def apply_omniauth_info_to_invite(token, auth)
@invite = Invite.find_incomplete_by_token!(token)
if invite
auth_info = HashWithIndifferentAccess.new(auth)
provider_name = Enthuse::SocialNetworkMappings.downcased_provider_to_camelcased(auth_info['provider'])
data = "#{provider_name}DataParser".constantize.new(auth_info)
@invite.set_authentication_provider_info data.as_json
@invite
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment