Created
February 7, 2011 19:35
-
-
Save jstewart/815024 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
class ApplicationController < ActionController::Base | |
before_filter :authenticate_user! | |
before_filter :authorize_admin | |
rescue_from UserNotAuthorized, :with => :handle_auth_exception | |
private | |
def handle_auth_exception | |
render :text => "401 Not Authorized", :status => :unauthorized | |
end | |
def authorize_admin | |
raise UserNotAuthorized unless current_user.is_admin? | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment