README.md in foyer-0.1.2 vs README.md in foyer-0.1.3

- old
+ new

@@ -7,13 +7,25 @@ `gem 'foyer'` ## Setup and Configuration -In your ApplicationController: +Setup as normal the `omniauth` gem. Remember to include in `routes.rb` the +implementating controller action that will call the `sign_in` method: ```ruby +Rails.application.routes.draw do + get '/auth/:provider/callback', to: 'omniauth_callbacks#callback' +end +``` + +You may extend the provided `Foyer::OmniauthCallbacksController`, as described +later in this document, to facilitate the implementation. + +Then in your ApplicationController: + +```ruby class ApplicationController < ActionController::Base include Foyer::Controller::Helpers set_user_finder do |user_id| # Code for retrieving a user from your database here @@ -28,11 +40,11 @@ ```ruby # config/initializers/foyer.rb Foyer.user_finder = lambda { |user_id| ... } ``` -Besiders `.user\_finder` there are some additional configuration +Besides `Foyer.user_finder` there are some additional configuration settings: ```ruby Foyer.identity_provider # The slug name of the omniauth provider your app uses Foyer.session_key # The key where Foyer will store user data in the session @@ -45,11 +57,11 @@ ### In Controllers Once the setup is complete, you will have the following methods available in controllers that include `Foyer::Controller::Helpers`: ``` -authenticate\_user! - Before filter that redirects unauthenticated users +authenticate_user! - Before filter that redirects unauthenticated users to omniauth sign_in(user) - Pass a user object to this method to sign that user in. User object must respond to #id @@ -62,11 +74,11 @@ sign_out - Signs out the authenticated user by clearing the session ``` ### In Views -`current\_user` and `user\_signed\_in?` are available as helper methods +`current_user` and `user_signed_in?` are available as helper methods in views. ### Routes This gem sets up a routing helper `authenticate` which allows you to set a @@ -102,10 +114,10 @@ includes the `Controller::Helpers` plus some additional useful helpers. You can inherit from it in your application. Example: ```ruby -class FoyerIdentityProviderController < ProviderAuthenticateable::OmniauthCallbacksController +class OmniauthCallbacksController < Foyer::OmniauthCallbacksController def callback user = User.find_or_initialize_by(uid: auth_hash.uid.to_s) do |u| u.email = auth_hash.info.email end