From 122f68c5cec937953dab0d42d0a7a0fa656806d7 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Wed, 30 Dec 2015 17:38:41 -0800 Subject: SessionsController: Add sample code provided by OmniAuth This is the sample callback code to get access to the OAuth auth hash. A new route specifies that `SessionsController#create` should handle the OAuth callback coming from Evernote. --- app/controllers/sessions_controller.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'app') diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 16d11b5..c755c69 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -1,2 +1,13 @@ class SessionsController < ApplicationController + def create + @user = User.find_or_create_from_auth_hash(auth_hash) + self.current_user = @user + redirect_to '/' + end + + protected + + def auth_hash + request.env['omniauth.auth'] + end end -- cgit v1.2.3