README.md in foyer-0.2.1 vs README.md in foyer-0.2.2
- old
+ new
@@ -12,11 +12,12 @@
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'
+ match '/auth/:provider/callback', to: 'omniauth_callbacks#callback', via: [:get, :post]
+ match '/auth/failure', to: 'omniauth_callbacks#failure', via: :get
end
```
You may extend the provided `Foyer::OmniauthCallbacksController`, as described
later in this document, to facilitate the implementation.
@@ -25,10 +26,13 @@
```ruby
class ApplicationController < ActionController::Base
include Foyer::Controller::Helpers
+ # Require authentication for all routes.
+ before_action authenticate_user!
+
set_user_finder do |user_id|
# Code for retrieving a user from your database here
# e.g.:
#
# User.find_by_id(user_id)
@@ -115,9 +119,13 @@
You can inherit from it in your application.
Example:
```ruby
class OmniauthCallbacksController < Foyer::OmniauthCallbacksController
+ def failure
+ redirect_to root_path, notice: 'Authentication failed!'
+ end
+
def callback
user = User.find_or_initialize_by(uid: auth_hash.uid.to_s) do |u|
u.email = auth_hash.info.email
end