adds password protection for staging and production servers
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
require "application_responder"
|
||||
|
||||
class ApplicationController < ActionController::Base
|
||||
before_filter :authenticate
|
||||
check_authorization unless: :devise_controller?
|
||||
include SimpleCaptcha::ControllerHelpers
|
||||
self.responder = ApplicationResponder
|
||||
@@ -15,6 +16,14 @@ class ApplicationController < ActionController::Base
|
||||
|
||||
before_action :ensure_signup_complete
|
||||
|
||||
def authenticate
|
||||
if Rails.env.staging? || Rails.env.production?
|
||||
authenticate_or_request_with_http_basic do |username, password|
|
||||
username == Rails.application.secrets.username && password == Rails.application.secrets.password
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
rescue_from CanCan::AccessDenied do |exception|
|
||||
redirect_to main_app.root_url, alert: exception.message
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user