19 lines
383 B
Ruby
19 lines
383 B
Ruby
class AdminController < ApplicationController
|
|
before_action :authorize_admin
|
|
|
|
def dashboard
|
|
end
|
|
|
|
def current_admin
|
|
user_args = { id: session[:user], role: 'admin' }
|
|
@current_admin ||= User.find_by(user_args) if session[:user]
|
|
end
|
|
helper_method :current_admin
|
|
|
|
private
|
|
|
|
def authorize_admin
|
|
redirect_to admin_login_path unless current_admin
|
|
end
|
|
end
|