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.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
new file mode 100644
index 0000000..ff06f02
--- /dev/null
+++ b/app/controllers/sessions_controller.rb
@@ -0,0 +1,23 @@
+class SessionController < ApplicationController
+ def new
+ # This route is catched by the Omniauth Middleware and is invisible to rake routes
+ redirect_to '/auth/github'
+ end
+
+ def create
+ user = User::Authenticable.authenticate(authorize_params)
+ session[:uid] = user.uid
+ redirect_to root_path
+ end
+
+ def destroy
+ session.delete(:uid)
+ redirect_to root_path
+ end
+
+ private
+
+ def authorize_params
+ request.env.fetch('omniauth.auth')
+ end
+end