class ApplicationController < ActionController::Base
    before_action :authorized
    helper_method :current_user
    helper_method :logged_in?

    def current_user
        User.find_by(id: session[:user_id])
    end

    def logged_in?
        !current_user.nil?
    end

    def matching_user?(obj)
        obj.user == current_user
    end

    def authorized
        redirect_to '/' unless logged_in?
    end
end
