Sha256: 75ea9a1d3af816f60f7f9c17fbe8ead8679621b31efef37048bb4ab36b315270

Contents?: true

Size: 808 Bytes

Versions: 1

Compression:

Stored size: 808 Bytes

Contents

module Fe::ApplicationControllerConcern
  extend ActiveSupport::Concern

  begin
    included do
      helper_method :fe_user
    end
  rescue ActiveSupport::Concern::MultipleIncludedBlocks
  end

  def fe_user
    return nil unless current_user
    @fe_user ||= Fe::User.where(:user_id => current_user.id).first
    if @fe_user
      @fe_user.update_attribute(:last_login, Time.now)
      session[:login_stamped] = true
    end
    @fe_user
  end

  def current_person
    #raise "no user" unless current_user
    return nil unless current_user
    current_user.fe_person || Fe::Person.create(:user_id => current_user.id)
  end

  def check_valid_user
    unless fe_user
      # TODO redirect to somewhere better
      redirect_to "/", flash: { error: "Access denied" }
      return false
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fe-0.0.4 app/controllers/fe/concerns/application_controller_concern.rb