Sha256: 24a1f4a2ba660ed2fcd06942c0b5b0094838ca3b5fb38e0707dffb2ed24aef6b

Contents?: true

Size: 747 Bytes

Versions: 1

Compression:

Stored size: 747 Bytes

Contents

module AppossLdapAdapter
  module Auth
    def sso_auth
      return if current_user
      if Rails.env == 'cucumber' or ENV['NOLOGIN']=='yes'
        user = User.find_or_create_by_email params['login_as']
        session[:user_id] = user.id
      else
        redirect_to '/auth/ldap'
      end
    end
    
    def current_user
      @user ||= User.find(session[:user_id]) if session[:user_id]
    end

    def callback
      begin
        email = env['omniauth.auth']['info']['email']
        user = User.find_or_create_by_email email
        session[:user_id] = user.id
        redirect_to '/'
      rescue Exception => e
        Rails.logger.error e.backtrace.join("\n")
        render :text => 'sign in failed.'
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
apposs_ldap_adapter-0.1.0 lib/apposs_ldap_adapter/auth.rb