Class: WebmasterRequired

Inherits:
Object
  • Object
show all
Defined in:
app/filters/WebmasterRequired.rb

Class Method Summary collapse

Class Method Details

.filter(controller) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/filters/WebmasterRequired.rb', line 2

def self.filter(controller)
  # Check if the user is even lgged in
  # If not then redirect them to the login page
  unless controller.session[:user]
  	controller.flash[:warning] = 'Please login to continue'
  	controller.session[:return_to] = controller.request.fullpath
  	controller.redirect_to :controller => 'users', :action => 'login'
  	return false
  end

  unless controller.session[:user] and controller.session[:user][:role] <= 0
    controller.flash[:warning] = 'You are not authorized for this part of the application!'
    controller.session[:return_to] = controller.request.fullpath
    controller.render :inline => "You are not authorized for this part of the application!  Return <a href='/'>home</a>"
    return false
  end
  
  return true
end