summaryrefslogtreecommitdiff
path: root/app/controllers/sessions_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/sessions_controller.rb')
-rw-r--r--app/controllers/sessions_controller.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
new file mode 100644
index 0000000..8d64438
--- /dev/null
+++ b/app/controllers/sessions_controller.rb
@@ -0,0 +1,17 @@
+class SessionsController < ApplicationController
+ def create
+ auth = request.env["omniauth.auth"]
+ Rails.logger.info auth
+ user = User.find_by_provider_and_uid(auth["provider"], auth["uid"]) || User.create_with_omniauth(auth)
+ session[:user_id] = user.id
+ redirect_to root_url, :notice => "Signed in!"
+ end
+
+ def destroy
+ session[:user_id] = nil
+ redirect_to root_url, :notice => "Signed out!"
+ end
+
+ def failure
+ end
+end