Skip to content

Instantly share code, notes, and snippets.

@StasKoval
Created March 28, 2013 19:55
Show Gist options
  • Save StasKoval/5266282 to your computer and use it in GitHub Desktop.
Save StasKoval/5266282 to your computer and use it in GitHub Desktop.
include OmniAuth::Strategy
option :fields, [:name, :email]
option :on_login, nil
option :on_registration, nil
option :on_failed_registration, nil
option :locate_conditions, lambda{|req| {model.auth_key => req['auth_key']} }
def request_phase
if options[:on_login]
options[:on_login].call(self.env)
else
OmniAuth::Form.build(
:title => (options[:title] || "Identity Verification"),
:url => callback_path
) do |f|
f.text_field 'Login', 'auth_key'
f.password_field 'Password', 'password'
f.html "<p align='center'><a href='#{registration_path}'>Create an Identity</a></p>"
end.to_response
end
end
def registration_path
options[:registration_path] || "#{path_prefix}/#{name}/register"
end
uid do
request.params[options.uid_field.to_s]
end
info do
options.fields.inject({}) do |hash, field|
hash[field] = request.params[field.to_s]
hash
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment