fluentd-ui/app/controllers/application_controller.rb
2014-05-13 17:02:32 +09:00

17 lines
474 B
Ruby

class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
helper_method :current_user
def current_user
return unless session[:remember_token]
@current_user ||= User.find_by(remember_token: session[:remember_token])
end
def login_required
return true if current_user
redirect_to new_sessions_path
end
end