Sha256: 53ee799f447b351132acf559ab9ecb10cf561cc158a8b5b65c2207ab228a3aea
Contents?: true
Size: 939 Bytes
Versions: 2
Compression:
Stored size: 939 Bytes
Contents
module CurrentUserHelpers def login_required if !current_user return respond_to do |format| format.html { redirect_to "#{SsoClyent.path}/auth/sso" } format.json { render :json => { 'error' => 'Access Denied' }.to_json } end end end def current_user return nil unless session[:user_id] users = user_klass uid = userid if users.respond_to?(:"find_by_#{uid}") @current_user ||= users.send(:"find_by_#{uid}", session[:user_id]['uid']) end end def user_signed_in? !!@current_user end def check_for_login_error api_response current_user_logout if !api_response.is_a? Array and api_response.try(:[],:error).try(:==,'401 Unauthorized') end def current_user_logout session[:user_id] = nil end def user_klass SsoClyent.user_class end def userid SsoClyent.unique_id end end ActionController::Base.send :include, CurrentUserHelpers
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sso_clyent-0.0.7.9 | lib/sso_clyent/controllers/current_user_helpers.rb |
sso_clyent-0.0.7.8 | lib/sso_clyent/controllers/current_user_helpers.rb |