Skip to content

Commit

Permalink
new optional advanced parameter for creating custom password encription
Browse files Browse the repository at this point in the history
  • Loading branch information
j1n6 committed Dec 20, 2013
1 parent ebcceac commit 1c4a14d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/devise_ldap_authenticatable.rb
@@ -1,5 +1,6 @@
# encoding: utf-8
require 'devise'
require 'net/ldap'

require 'devise_ldap_authenticatable/exception'
require 'devise_ldap_authenticatable/logger'
Expand Down Expand Up @@ -34,6 +35,9 @@ module Devise
mattr_accessor :ldap_auth_username_builder
@@ldap_auth_username_builder = Proc.new() {|attribute, login, ldap| "#{attribute}=#{login},#{ldap.base}" }

mattr_accessor :ldap_auth_password_builder
@@ldap_auth_password_builder = Proc.new() {|new_password| Net::LDAP::Password.generate(:ssha, new_password) }

mattr_accessor :ldap_ad_group_check
@@ldap_ad_group_check = false
end
Expand Down
2 changes: 1 addition & 1 deletion lib/devise_ldap_authenticatable/ldap/adapter.rb
Expand Up @@ -26,7 +26,7 @@ def self.update_password(login, new_password)
end

def self.update_own_password(login, new_password, current_password)
set_ldap_param(login, :userpassword, Net::LDAP::Password.generate(:sha, new_password), current_password)
set_ldap_param(login, :userPassword, ::Devise.ldap_auth_password_builder.call(new_password), current_password)
end

def self.ldap_connect(login)
Expand Down

0 comments on commit 1c4a14d

Please sign in to comment.