Skip to content

Instantly share code, notes, and snippets.

@mokevnin
Created January 30, 2012 08:55
Show Gist options
  • Select an option

  • Save mokevnin/1703430 to your computer and use it in GitHub Desktop.

Select an option

Save mokevnin/1703430 to your computer and use it in GitHub Desktop.
module ConfirmationHelper
extend ActiveSupport::Concern
include AuthHelper
included do
alias_method_chain :sign_out, :confirmation_request_clear
end
module InstanceMethods
def sign_out_with_confirmation_request_clear
sign_out_without_confirmation_request_clear
clear_provider_confirmation_request
end
def request_provider_confirmation(user, provider, data)
session[:provider] = {
:user_id => user.id,
:name => provider,
:uid => uid(data)
}
end
def requested_provider_confirmation?(user)
if p_data = session[:provider]
p_data[:user_id] == user.id && p_data[:name] && p_data[:uid]
end
end
def clear_provider_confirmation_request
session[:provider] = nil
end
def provider_confirmation_requestor
if p_data = session[:provider]
p_data[:user_id]
end
end
def provider_confirm_data
{
'uid' => session[:provider][:uid]
}
end
def provider_name
session[:provider][:name]
end
def uid(data)
data.fetch('uid')
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment