class AdminRequired 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] <= 1 controller.flash[:warning] = 'Please login to continue' controller.session[:return_to] = controller.request.fullpath controller.render :inline => "You are not authorized for this part of the application! Return home" return false end return true end end