Module: Vhost::ControllerAccessExtensions

Defined in:
lib/vhost/controller_access_extensions.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(receiver) ⇒ Object



2
3
4
# File 'lib/vhost/controller_access_extensions.rb', line 2

def self.included(receiver)
  receiver.send :before_filter, :ensure_user_has_site_access
end

Instance Method Details

#ensure_user_has_site_accessObject



6
7
8
9
10
11
12
13
14
# File 'lib/vhost/controller_access_extensions.rb', line 6

def ensure_user_has_site_access
  unless current_site.allow_access_for(current_user)
    cookies[:session_token] = { :expires => 1.day.ago }
    self.current_user.forget_me if self.current_user
    self.current_user = nil
    flash[:error] = 'Access denied.'
    redirect_to 
  end
end