2016-07-26 11:59:23 -05:00
|
|
|
class ApplicationController < ActionController::Base
|
|
|
|
protect_from_forgery with: :exception
|
2016-07-29 11:53:01 -05:00
|
|
|
|
2016-07-31 09:56:02 -05:00
|
|
|
def current_recruiter
|
2016-07-31 16:34:35 -05:00
|
|
|
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]
|
2016-07-31 09:56:02 -05:00
|
|
|
end
|
|
|
|
|
2016-07-29 11:53:01 -05:00
|
|
|
def current_candidate
|
2016-07-31 09:56:02 -05:00
|
|
|
@current_candidate ||= Candidate.find_by(test_hash: session[:test_id]) if session[:test_id]
|
2016-07-29 11:53:01 -05:00
|
|
|
end
|
2016-08-02 18:30:15 -05:00
|
|
|
helper_method :current_candidate
|
2016-07-31 09:56:02 -05:00
|
|
|
|
2016-08-24 08:23:29 -05:00
|
|
|
def styleguide
|
|
|
|
render '/styleguide'
|
|
|
|
end
|
|
|
|
|
2016-07-31 09:56:02 -05:00
|
|
|
private
|
|
|
|
|
|
|
|
def auth_params
|
|
|
|
params.require(:auth).permit(:email, :password)
|
|
|
|
end
|
|
|
|
|
|
|
|
def authorize_recruiter
|
|
|
|
redirect_to recruiter_login_path unless current_recruiter
|
|
|
|
end
|
2016-07-31 16:34:35 -05:00
|
|
|
|
|
|
|
def authorize_reviewer
|
|
|
|
redirect_to review_login_path unless current_reviewer
|
|
|
|
end
|
2016-07-31 18:54:12 -05:00
|
|
|
|
|
|
|
def authorize_candidate
|
2016-08-02 18:02:20 -05:00
|
|
|
redirect_to login_path unless current_candidate
|
2016-07-31 18:54:12 -05:00
|
|
|
end
|
2016-07-26 11:59:23 -05:00
|
|
|
end
|