Sha256: 84abe797ff6c1c7965146cbb1d322ad55a130d9d4204500ff07ee3faecca2169

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

require 'chaltron/ldap/user'

module Chaltron
  class OmniauthCallbacksController < Devise::OmniauthCallbacksController

  default_log_category :login

    def ldap
      puts '##########################################'
      puts oauth.inspect
      puts '##########################################'
      puts params.inspect
      puts '##########################################'
      # We only find ourselves here
      # if the authentication to LDAP was successful.
      user = Chaltron::LDAP::User.find_or_create(oauth, Chaltron.ldap_allow_all)
      if user.nil?
        redirect_to root_url, alert: I18n.t('chaltron.not_allowed_to_sign_in')
      else
        user.remember_me = params[:remember_me] if user.persisted?
        flash[:notice] = I18n.t('devise.sessions.signed_in')

        info I18n.t('chaltron.logs.login_via', user: user.display_name, provider: 'ldap')
        sign_in_and_redirect(user)
      end
    end

    private

    def oauth
      @oauth ||= request.env['omniauth.auth']
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chaltron-0.1.2 app/controllers/chaltron/omniauth_callbacks_controller.rb~