Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ApplicationController < ActionController::Base
- # ...
- helper_method :admin?
- private
- def admin?
- ##
- # Turns out this doesn't work on actions
- # where authorize isn't called
- #
- #request.env['HTTP_AUTHORIZATION'] ||
- #request.env['X-HTTP_AUTHORIZATION'] ||
- #request.env['X_HTTP_AUTHORIZATION'] ||
- #request.env['REDIRECT_X_HTTP_AUTHORIZATION']
- #
- # This on the other hand does
- #request_http_basic_authentication
- #
- # No..... It Didn't.
- # Now what do we do?
- true
- end
- protected
- def authorize
- authenticate_or_request_with_http_basic do |username, password|
- username == "foo" && password == "bar"
- end
- end
- end
Add Comment
Please, Sign In to add comment