Class: Chaltron::OmniauthCallbacksController

Inherits:
Devise::OmniauthCallbacksController
  • Object
show all
Defined in:
app/controllers/chaltron/omniauth_callbacks_controller.rb

Instance Method Summary collapse

Instance Method Details

#ldapObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/chaltron/omniauth_callbacks_controller.rb', line 8

def ldap
#      puts '##########################################'
#      puts oauth.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)
  user = Chaltron.ldap_after_authenticate.call(user, Chaltron::LDAP::Connection.new)
  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')
    (user)
  end
end