app/controllers/application.rb
def authorize
    @current_user = nil
    
    # Check if user is not logged in - redirect him to login page.
    unless session[:user_id]
      flash[:notice] = "Please log in"
      redirect_to(:controller => "login", :action => "login") and return false
    end
    
    # User is logged in, restore record
    @current_user=User.find(session[:user_id]);
    
    # Check if user is inactive - redirect him to 'inactive' page
    if @current_user.is_inactive
      render :partial => "users/inactive", :layout => "main" and return false
    end
    
    # Check user permissions
    unless @current_user.has_permissions_to?(params[:controller], params[:action])
      # user is not allowed to view the page. Show proper info
      render :partial => "/users/no_permissions", :layout => "main" and return false
    end
  end
#
# Checks if +normal user+ is logged in, is active, and has permissions to access requested controller/action
# This method is present in most before_filters, to authorize users
# This method sets up +@current_user+
# If user is not authorized, shows "no_permission" partial.
#

Checks if +normal user+ is logged in, is active, and has permissions to access requested controller/action
This method is present in most before_filters, to authorize users
This method sets up +@current_user+
If user is not authorized, shows "no_permission" partial.
Checks if + normal user + is logged in is active and has permissions to access requested controller / action This method is present in most before_filters to authorize users This method sets up + @current_user + If user is not authorized shows " no_permission " partial .
def authorize
    @current_user = nil
    unless session[:user_id]
      flash[:notice] = "Please log in"
      redirect_to(:controller => "login", :action => "login") and return false
    end
    @current_user=User.find(session[:user_id]);
    if @current_user.is_inactive
      render :partial => "users/inactive", :layout => "main" and return false
    end
    unless @current_user.has_permissions_to?(params[:controller], params[:action])
      render :partial => "/users/no_permissions", :layout => "main" and return false
    end
  end
def authorize @current_user = nil unless session [ :user_id ] flash [ :notice ] = "Please log in" redirect_to ( :controller => "login" , :action => "login" ) and return false end @current_user = User . find ( session [ :user_id ] ) ; if @current_user . is_inactive render :partial => "users/inactive" , :layout => "main" and return false end unless @current_user . has_permissions_to? ( params [ :controller ] , params [ :action ] ) render :partial => "/users/no_permissions" , :layout => "main" and return false end end
Checks if +normal user+ is logged in, is active, and has permissions to access requested controller/action
This method is present in most before_filters, to authorize users
This method sets up +@current_user+
If user is not authorized, shows "no_permission" partial.
Checks if + normal user + is logged in is active and has permissions to access requested controller / action This method is present in most before_filters to authorize users This method sets up + @current_user + If user is not authorized shows " no_permission " partial .
# Check if user is not logged in - redirect him to login page.
 # User is logged in, restore record
 # Check if user is inactive - redirect him to 'inactive' page
 # Check user permissions
 # user is not allowed to view the page. Show proper info
