Last active
December 11, 2015 07:08
-
-
Save b-murphy/4564165 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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