Created
August 24, 2019 01:26
-
-
Save rwehresmann/95c98c6eb3bb7ae84a251da7a852f4d7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Admin | |
| class ApplicationController < Administrate::ApplicationController | |
| before_action :authenticate_admin | |
| helper_method :current_user | |
| def authenticate_admin | |
| if current_user.nil? || current_user.admin? == false | |
| flash[:alert] = 'You do not have authorization to access this page.' | |
| redirect_to root_path | |
| end | |
| end | |
| def current_user | |
| @current_user ||= User.find_by(id: session[:user_id]) | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment