bhoggard/submitter

View on GitHub
app/controllers/application_controller.rb

Summary

Maintainability
A
0 mins
Test Coverage
class ApplicationController < ActionController::Base
  protect_from_forgery

  if Rails.configuration.post_raffle
    http_basic_authenticate_with name: Rails.configuration.artist_auth_name,
                                 password: Rails.configuration.artist_auth_pass
  end

  def current_user
    @current_user ||= User.find(session[:user_id]) if session[:user_id]
  end

  helper_method :current_user

  def admin?
    false
  end

  private

  def set_caching
    response.headers['Cache-Control'] = 'public, max-age=1800'
  end

  # rubocop:disable LineLength
  # check whether admin is logged in
  def authenticate!
    redirect_to login_path, notice: 'You must be logged in to visit that page' unless current_user
  end

  def load_work
    @work = Work.find(params[:id])
  end
end