4bbd93ded1
Adding the .ruby-verison file triggered previously un-run cops, specifically: This cop is designed to help upgrade to Ruby 3.0. It will add the comment `# frozen_string_literal: true` to the top of files to enable frozen string literals. Frozen string literals will be default in Ruby 3.0. The comment will be added below a shebang and encoding comment. The frozen string literal comment is only valid in Ruby 2.3+. More info on rubocop [Automatic-Corrections](https://github.com/bbatsov/rubocop/wiki/Automatic-Corrections)
44 lines
1.1 KiB
Ruby
44 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
class ApplicationController < ActionController::Base
|
|
protect_from_forgery with: :exception
|
|
|
|
add_flash_types :warning, :success
|
|
|
|
def current_recruiter
|
|
user_parms = { id: session[:user], role: %w(admin recruiter) }
|
|
@current_recruiter ||= User.find_by(user_parms) if session[:user]
|
|
end
|
|
|
|
def current_reviewer
|
|
user_parms = { id: session[:user], role: %w(admin reviewer) }
|
|
@current_reviewer ||= User.find_by(user_parms) if session[:user]
|
|
end
|
|
|
|
def current_candidate
|
|
@current_candidate ||= Candidate.find_by(test_hash: session[:test_id]) if session[:test_id]
|
|
end
|
|
helper_method :current_candidate
|
|
|
|
def styleguide
|
|
render '/styleguide'
|
|
end
|
|
|
|
private
|
|
|
|
def auth_params
|
|
params.require(:auth).permit(:email, :password)
|
|
end
|
|
|
|
def authorize_recruiter
|
|
redirect_to recruiter_login_path unless current_recruiter
|
|
end
|
|
|
|
def authorize_reviewer
|
|
redirect_to review_login_path unless current_reviewer
|
|
end
|
|
|
|
def authorize_candidate
|
|
redirect_to login_path unless current_candidate
|
|
end
|
|
end
|