Sha256: 45b0e84b366a3fa1beda039a66137ac66de1839271ad1c4825690e8ebaa0309a

Contents?: true

Size: 649 Bytes

Versions: 3

Compression:

Stored size: 649 Bytes

Contents

class ApplicationController < ActionController::Base
  def current_user
    cu = super           
    if defined? Cream::Role
      # Try to get instance of any of the available roles as the current user
      Cream::Role.available.each do |role|
        method = :"current_#{role}"
        cu ||= send method if respond_to?(method)
      end
    end    
    # if all else fails, the user is likely not signed in so create a Guest user for now    
    cu ||= Guest.create if defined?(Guest)
  end

  def user_signed_in?
    current_user && !current_user.has_role?(:guest)
  end

  def user_session
    user_signed_in? ? super : session
  end    
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cream-0.8.9 lib/cream/controller/application_controller.rb
cream-0.8.8 lib/cream/controller/application_controller.rb
cream-0.8.7 lib/cream/controller/application_controller.rb