mirror of
https://github.com/System-End/theseus.git
synced 2026-04-19 19:55:10 +00:00
21 lines
694 B
Ruby
21 lines
694 B
Ruby
# All Administrate controllers inherit from this
|
|
# `Administrate::ApplicationController`, making it the ideal place to put
|
|
# authentication logic or other before_actions.
|
|
#
|
|
# If you want to add pagination or other controller-level concerns,
|
|
# you're free to overwrite the RESTful controller actions.
|
|
module Admin
|
|
class ApplicationController < Administrate::ApplicationController
|
|
before_action :authenticate_admin
|
|
|
|
def authenticate_admin
|
|
redirect_to root_path, alert: "you can't do that!" unless current_user&.admin?
|
|
end
|
|
|
|
helper_method :current_user
|
|
|
|
def current_user
|
|
@current_user ||= User.find_by(id: session[:user_id]) if session[:user_id]
|
|
end
|
|
end
|
|
end
|