app/controllers/mtdevise/application_controller.rb in mtdevise-1.5.2 vs app/controllers/mtdevise/application_controller.rb in mtdevise-1.5.3
- old
+ new
@@ -1,12 +1,13 @@
module Mtdevise
# class ApplicationController < ActionController::Base
class ApplicationController < ::ApplicationController
- around_filter :catch_not_found
protect_from_forgery with: :null_session
+ before_action :check_subdomain
+
def after_sign_in_path_for(resource)
request.env['omniauth.origin'] || stored_location_for(resource) || mtdevise.accounts_path
end
# Starting to Add User Helpers
@@ -22,17 +23,17 @@
helper_method :current_account
private
- def catch_not_found
- yield
- rescue ActiveRecord::RecordNotFound
- redirect_to mtdevise.root_url, :flash => { :error => "Account Not Found Please Register." }
- end
-
def redirect_logged_in_users_to_account_page
redirect_to mtdevise.accounts_path if user_signed_in?
+ end
+
+ def check_subdomain
+ if request.subdomain.present? && Account.where(subdomain: request.subdomain).blank?
+ redirect_to mtdevise.root_url(subdomain: false), notice: "Subdomain Doesn't Exist. Would you like to Register."
+ end
end
end
end
\ No newline at end of file