tinyforms/app/controllers/application_controller.rb
Yannick ab81cf9d5c Added logout button
Added logged_in helper to allow us to check whether a user is logged in
to show the appropriate button
2020-04-07 20:52:45 +02:00

16 lines
319 B
Ruby

class ApplicationController < ActionController::Base
helper_method :current_user, :logged_in?
def require_login
redirect_to login_url unless current_user.present?
end
def current_user
session[:user_id] && User.find_by(id: session[:user_id])
end
def logged_in?
current_user.present?
end
end