Sha256: 9bc2581b60573456b967242ec65e012f10d1a5a57dfdaba12e677de5ea48d8e9

Contents?: true

Size: 661 Bytes

Versions: 42

Compression:

Stored size: 661 Bytes

Contents

module Edgarj
  module AuthenticationMixin
    def self.included(klass)
      klass.helper_method :current_user
    end

  private
    def access_denied
      flash.now[:error] = v('login_failed')
     #redirect_to login_path
      respond_to do |format|
        format.html {
          render '/edgarj/sssns/new', layout: 'login'
        }
        format.js {
          render '/edgarj/sssns/new'
        }
      end
    end

    # before_filter to enforce a login requirement.
    def require_login
      !!current_user || access_denied
    end

    def current_user
      @current_user ||= User.find(session[:user_id]) if session[:user_id]
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
edgarj-0.01.13 app/controllers/edgarj/authentication_mixin.rb.sample
edgarj-0.01.12 app/controllers/edgarj/authentication_mixin.rb.sample