]> source.dussan.org Git - redmine.git/commitdiff
Better error message and AR errors in log for failed LDAP on-the-fly user creation...
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 13 Apr 2008 09:12:43 +0000 (09:12 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 13 Apr 2008 09:12:43 +0000 (09:12 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1345 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/account_controller.rb
app/models/user.rb

index e719e8c9bd3b802e51514b61969a371993d8368f..b9224c158e174057081a8d663fd4f69a4716d85b 100644 (file)
@@ -56,6 +56,8 @@ class AccountController < ApplicationController
         flash.now[:error] = l(:notice_account_invalid_creditentials)
       end
     end
+  rescue User::OnTheFlyCreationFailure
+    flash.now[:error] = 'Redmine could not retrieve the required information from the LDAP to create your account. Please, contact your Redmine administrator.'
   end
 
   # Log out current user and redirect to welcome page
index e0b1e238c080361ae122579401ebd8818ab7b51a..a67a085675b3510252519f7909fea90d88395f7f 100644 (file)
@@ -18,6 +18,9 @@
 require "digest/sha1"
 
 class User < ActiveRecord::Base
+
+  class OnTheFlyCreationFailure < Exception; end
+
   # Account statuses
   STATUS_ANONYMOUS  = 0
   STATUS_ACTIVE     = 1
@@ -105,15 +108,17 @@ class User < ActiveRecord::Base
         onthefly.language = Setting.default_language
         if onthefly.save
           user = find(:first, :conditions => ["login=?", login])
-          logger.info("User '#{user.login}' created on the fly.") if logger
+          logger.info("User '#{user.login}' created from the LDAP") if logger
+        else
+          logger.error("User '#{onthefly.login}' found in LDAP but could not be created (#{onthefly.errors.full_messages.join(', ')})") if logger
+          raise OnTheFlyCreationFailure.new
         end
       end
     end    
     user.update_attribute(:last_login_on, Time.now) if user
     user
-    
-    rescue => text
-      raise text
+  rescue => text
+    raise text
   end
        
   # Return user's full name for display