add ldap support

Achtung dieses diff benötigt einen neuen Eintrag im secrets config file
This commit is contained in:
Andreas Stephanides
2013-10-26 12:48:40 +02:00
parent 91d0e4cf75
commit 37ee03676e
5 changed files with 84 additions and 20 deletions

View File

@@ -1,10 +1,17 @@
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
def facebook
skip_before_filter :verify_authenticity_token
def failure
# flash[:notice] = "Failure #{Hash.new(request.env)} #{Hash.new(params)}"
#redirect_to new_user_registration_url , :notice=>"Omniauth Login failed"
super
end
def facebook
# You need to implement the method below in your model (e.g. app/models/user.rb)
@user = User.find_for_facebook_oauth(request.env["omniauth.auth"], current_user)
if @user.persisted?
if @user
sign_in_and_redirect @user, :event => :authentication #this will throw if @user is not activated
set_flash_message(:notice, :success, :kind => "Facebook") if is_navigational_format?
else
@@ -12,4 +19,25 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
redirect_to new_user_registration_url
end
end
def ldap
logger.debug current_user.to_s
@user=User.find_for_ldap_oauth(request.env["omniauth.auth"],current_user)
# @user=User.find_for_ldap_oauth(session["devise.ldap_data"],current_user)
# @user=User.first
# flash[:notice]="#{request.env}"
# sign_in_and_redirect @user, :event=>:authentication
# debug @user
#debug
# logger.info "Request attributes hash: #{request.env}"
if @user
sign_in_and_redirect @user, :event => :authentication
set_flash_message(:notice,:success,:kind=>"Ldap") if is_navigational_format?
else
session["devise.ldap_data"]=request.env["omniauth.auth"]
# set_flash_message(:notice, "sdfsdf")
flash[:notice]=flash[:notice] + "Still not logged in "
redirect_to new_user_registration_url
end
end
end