From 03d880f64dbab14b8ad7ca2e0c84ea576c9b2311 Mon Sep 17 00:00:00 2001 From: Xueqiao Xu Date: Sun, 4 May 2014 11:02:48 -0700 Subject: [PATCH 1/4] Fix: use Rails.logger instead of logger It is required when using logger outside models or controllers. Otherwise the logger is undefined. --- lib/active_directory.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/active_directory.rb b/lib/active_directory.rb index f1d39fd90..c97987805 100644 --- a/lib/active_directory.rb +++ b/lib/active_directory.rb @@ -13,14 +13,14 @@ def create_active_directory_account(user) return "Empty email address" if user.email.blank? # log what is happening - logger.debug("Attempting to create active directory account for " + user.email) + Rails.logger.debug("Attempting to create active directory account for " + user.email) # extract domain from email domain = user.email.split('@')[1] # Confirm domain name accuracy if domain != GOOGLE_DOMAIN - logger.debug("Domain (" + domain + ") is not the same as the google domain (" + GOOGLE_DOMAIN) + Rails.logger.debug("Domain (" + domain + ") is not the same as the google domain (" + GOOGLE_DOMAIN) return "Domain (" + domain + ") is not the same as the google domain (" + GOOGLE_DOMAIN + ")" end From e4097b7007142b7d5a70c172ad7a44e6c3cb9c5f Mon Sep 17 00:00:00 2001 From: Xueqiao Xu Date: Sun, 4 May 2014 11:51:11 -0700 Subject: [PATCH 2/4] Fix user active directory account timestamp --- lib/active_directory.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/active_directory.rb b/lib/active_directory.rb index c97987805..572c83de6 100644 --- a/lib/active_directory.rb +++ b/lib/active_directory.rb @@ -27,7 +27,7 @@ def create_active_directory_account(user) # Attempt to create active directory account active_directory_service = ActiveDirectory.new if active_directory_service.create_account(user) == "Success" - user.active_directory_account_created = Time.now() + user.active_directory_account_created_at = Time.now() user.save end end From 973e8fb7398e2e638d286bfb285bc43190edb12b Mon Sep 17 00:00:00 2001 From: Xueqiao Xu Date: Sun, 4 May 2014 11:52:28 -0700 Subject: [PATCH 3/4] Fix constructor of active directory --- lib/active_directory.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/active_directory.rb b/lib/active_directory.rb index 572c83de6..26fe4a83e 100644 --- a/lib/active_directory.rb +++ b/lib/active_directory.rb @@ -34,7 +34,7 @@ def create_active_directory_account(user) # Initialize connection to active directory - def self.initialize + def initialize @connection = Net::LDAP.new(:host => LDAPConfig.host, :port => LDAPConfig.port) @connection.encryption(:method => :simple_tls) unless !LDAPConfig.is_encrypted? @connection.auth LDAPConfig.username, LDAPConfig.password unless LDAPConfig.username.nil? || LDAPConfig.password.nil? From f8b239a63d210c098a912b3df80730477d2fd1c9 Mon Sep 17 00:00:00 2001 From: Xueqiao Xu Date: Sun, 4 May 2014 11:54:56 -0700 Subject: [PATCH 4/4] Fix setting user.passwrod_reset_sent_at --- lib/active_directory.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/active_directory.rb b/lib/active_directory.rb index 26fe4a83e..4bf29d6a3 100644 --- a/lib/active_directory.rb +++ b/lib/active_directory.rb @@ -108,7 +108,7 @@ def password_encode(password) # Send active directory password reset token def send_password_reset_token(user) user.set_password_reset_token - self.password_reset_sent_at = Time.zone.now + user.password_reset_sent_at = Time.zone.now user.save! PasswordMailer.password_reset(user).deliver end