Add user admin
This commit is contained in:
14
app/controllers/admin/base_controller.rb
Normal file
14
app/controllers/admin/base_controller.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
module Admin
|
||||
class BaseController < ApplicationController
|
||||
before_action :require_admin
|
||||
|
||||
private
|
||||
|
||||
def require_admin
|
||||
user = Current.session&.user
|
||||
unless user&.admin?
|
||||
redirect_to root_path, alert: "You must be an administrator to access this page."
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user