rails 4 introduced different strategies, but we never configured one so it would default to a null session.
21 lines
386 B
Ruby
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
|