From 16d6b7c389f751636ec2eff56d6cf2846c70ca2a Mon Sep 17 00:00:00 2001 From: Joerg Reichert Date: Sun, 10 Apr 2016 15:24:58 +0200 Subject: [PATCH] readd sessions_controller --- app/controllers/sessions_controller.rb | 19 +++++++++++++++++++ config/routes.rb | 2 ++ 2 files changed, 21 insertions(+) create mode 100644 app/controllers/sessions_controller.rb diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb new file mode 100644 index 0000000..6880b58 --- /dev/null +++ b/app/controllers/sessions_controller.rb @@ -0,0 +1,19 @@ +class SessionsController < ApplicationController + def create + if user = User.find_or_create_from_auth_hash(auth_hash) + session[:user_id] = user.id + end + redirect_to root_path + end + + def destroy + reset_session + redirect_to root_path + end + + protected + + def auth_hash + request.env['omniauth.auth'] + end +end \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 7d013d1..0df64de 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,6 +3,8 @@ Rails.application.routes.draw do post '/import' => 'import#new_papers_callback' get '/' => 'search#index', as: :search + + resource :session, only: [:create, :destroy] # Example of regular route: # get 'products/:id' => 'catalog#view'