2012-09-16 07:44:54 -04:00
|
|
|
# Provides a base class for Admin controllers to subclass
|
|
|
|
#
|
|
|
|
# Automatically sets the layout and ensures an administrator is logged in
|
2013-01-20 06:20:50 -05:00
|
|
|
class Admin::ApplicationController < ApplicationController
|
2015-04-16 08:03:37 -04:00
|
|
|
before_action :authenticate_admin!
|
2015-05-01 04:39:11 -04:00
|
|
|
layout 'admin'
|
2012-09-16 07:44:54 -04:00
|
|
|
|
|
|
|
def authenticate_admin!
|
|
|
|
return render_404 unless current_user.is_admin?
|
|
|
|
end
|
2015-10-28 11:39:23 -04:00
|
|
|
|
|
|
|
def authorize_impersonator!
|
|
|
|
if session[:impersonator_id]
|
|
|
|
User.find_by!(username: session[:impersonator_id]).admin?
|
|
|
|
end
|
|
|
|
end
|
2012-09-16 07:44:54 -04:00
|
|
|
end
|