Sha256: 06ee0458d4b587a33275219476c4a204c243daad68c99626bcf4946a645afa0b
Contents?: true
Size: 1.17 KB
Versions: 3
Compression:
Stored size: 1.17 KB
Contents
require 'active_support/concern' module Omniauth module HasCurrentUser extend ActiveSupport::Concern included do helper_method :current_user end module ClassMethods def has_current_user include Omniauth::HasCurrentUser::InstanceMethods end end module InstanceMethods @user = nil def current_user return nil unless @user.present? || session[:current_user].present? @user = @user || User.unmarshal( session[:current_user] ) @user end def current_user=(user) @user = user session[:current_user] = @user.marshal unless @user.nil? end def authenticate! return if authenticated? session[:return_to] = request.url if Rails.env.development? redirect_to "/auth/developer" else redirect_to "/auth/aai" end end def authenticated? return true if self.current_user.present? && self.current_user.uid.present? return false end end end end begin ActionController::Base.send :include, Omniauth::HasCurrentUser rescue NameError => e puts "ActionController undefined" end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
omniauth-aai-0.6.9 | lib/omniauth/has_current_user.rb |
omniauth-aai-0.6.8 | lib/omniauth/has_current_user.rb |
omniauth-aai-0.6.6 | lib/omniauth/has_current_user.rb |