Sha256: 7e61b4dcb620d06beacb91b8b38f1ac4349cef19bbcc8d2c294ab991778b8428
Contents?: true
Size: 1.81 KB
Versions: 3
Compression:
Stored size: 1.81 KB
Contents
=============================================================================== Some setup you must do manually if you haven't yet: 1. configure your User model (mongo_mapper example): class User ... key :auth_keys, Array def self.authenticate(fields) auth_key = "#{fields["provider"]}_#{fields["uid"]}" user = User.first(:auth_keys => auth_key) if user.nil? user = User.new(:auth_keys => [auth_key]) user.send(:auth_fields=, fields["user_info"]) user.save! end user end def connect(fields) auth_key = "#{fields["provider"]}_#{fields["uid"]}" user = User.first(:auth_keys => auth_key, :select => [:id]) if user.present? && user.id != self.id user.destroy if merge_account(user) end self.push_uniq(:auth_keys => auth_key) end def merge_account(other_user) # return true to delete the old user true end def auth_fields=(info) Rails.logger.info "FIELDS: #{info.inspect}" info.each_pair do |k, v| self[k] = v end end end 2. configure the service keys at config/auth_providers.yml Default routes: /sessions/sign_in /sessions/sign_out you can override them using the following routes: match "/login" => "multiauth/sessions#new", :as => :new_session match "/logout" => "multiauth/sessions#destroy", :method => :get, :as => :destroy_session you can override the default view creating the file: app/views/multiauth/sessions/new.html.haml to render the auth providers as a dropdown menu use: <%= multiauth_menu("connect your account") %> you can render single links as follows: <%= multiauth_link("Google") %> ===============================================================================
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
multiauth-0.2.7 | lib/generators/templates/README |
multiauth-0.2.6 | lib/generators/templates/README |
multiauth-0.2.3 | lib/generators/templates/README |