Last active
August 29, 2015 14:05
-
-
Save aishek/ad1fb8ac2147da393c64 to your computer and use it in GitHub Desktop.
gem six auth ror admin example
This file contains 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
# app/controllers/web/admin/application_controller.rb | |
class Web::ApplicationController < Web::ApplicationController | |
include Concerns::Auth | |
rescue_from AccessDenied, :with => :access_denied_handler | |
private | |
def can?(action, subject = current_admin_user) | |
abilities << subject | |
abilities.allowed?(current_admin_user, action, subject) | |
end | |
def current_admin_user_session | |
@current_admin_user_session ||= ::Admin::User::Session.find | |
end | |
def current_admin_user | |
@current_user ||= (current_admin_user_session && current_admin_user_session.record) || Admin::Guest.new | |
end | |
def access_denied_handler | |
flash[:error] = t('helpers.auth.unauthorized') | |
redirect_back_or_default admin_auth_login_path | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment