Sha256: ad0d9ecedd805eb1e47bc40edc8ffb97bf521d062623eba74a6abd76abc22239

Contents?: true

Size: 828 Bytes

Versions: 1

Compression:

Stored size: 828 Bytes

Contents

class WebmasterRequired
  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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fs_auth-0.0.1 app/filters/WebmasterRequired.rb