aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
authorTeddy Wing2015-12-30 17:38:41 -0800
committerTeddy Wing2015-12-30 17:45:28 -0800
commit122f68c5cec937953dab0d42d0a7a0fa656806d7 (patch)
tree77055272b140ea499f9dec3e6d4c4902dbc0383a /app/controllers
parenta443de365cc1ccfb57cbc416c4d780df9c9a0033 (diff)
downloadEvernote-Rails-Example-122f68c5cec937953dab0d42d0a7a0fa656806d7.tar.bz2
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.
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/sessions_controller.rb11
1 files changed, 11 insertions, 0 deletions
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