scube-server/app/controllers/application_controller.rb
Thibault Jouan 3e5c29b635 Configure CSRF protection with exceptions
rails 4 introduced different strategies, but we never configured one
so it would default to a null session.
2015-04-30 11:43:22 +00:00

21 lines
386 B
Ruby

class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_filter :authenticate!
def current_user= user
session[:user_id] = user.id
end
def current_user
@current_user ||= User.find(session[:user_id]) if session[:user_id]
end
protected
def authenticate!
redirect_to new_session_path if current_user.nil?
end
end