LDAP connection and modified Devise

This commit is contained in:
Matt Fu committed 2012-02-22 14:43:24 +08:00
1 parent 9cd3cbc478
commit 678f1eabef
22 files changed
+245 -17

No files matched your search

+5
View File
@@ -21,6 +21,8 @@ Devise.setup do |config|
# parameters are used only when authenticating and not when retrieving from
# session. If you need permissions, you should implement that in a before filter.
# config.authentication_keys = [ :email ]
config.authentication_keys = [ :nccu_ldap_uid ]
# Tell if authentication through request.params is enabled. True by default.
# config.params_authenticatable = true
@@ -139,4 +141,7 @@ Devise.setup do |config|
# end
# manager.default_strategies(:scope => :user).unshift :twitter_oauth
# end
config.warden do |manager|
manager.default_strategies.unshift :check_nccu_ldap
end
end
+19
View File
@@ -0,0 +1,19 @@
# Warden::Strategies.add(:check_nccu_ldap) do
# def valid?
# # code here to check whether to try and authenticate using this strategy;
# params['nccu_ldap_uid'] && params['password']
# end
# def authenticate!
# debugger
# user = User.first(conditions:{ nccu_ldap_uid: "901001" })
# if user
# success! user
# else
# success! User.create
#
# # fail!(message)
# # User.create
# end
# end
#
# end