##// END OF EJS Templates
Better error message and AR errors in log for failed LDAP on-the-fly user creation (closes #932, #1042)....
Jean-Philippe Lang -
r1330:a340d8c957bb
parent child
Show More
@@ -56,6 +56,8 class AccountController < ApplicationController
56 flash.now[:error] = l(:notice_account_invalid_creditentials)
56 flash.now[:error] = l(:notice_account_invalid_creditentials)
57 end
57 end
58 end
58 end
59 rescue User::OnTheFlyCreationFailure
60 flash.now[:error] = 'Redmine could not retrieve the required information from the LDAP to create your account. Please, contact your Redmine administrator.'
59 end
61 end
60
62
61 # Log out current user and redirect to welcome page
63 # Log out current user and redirect to welcome page
@@ -18,6 +18,9
18 require "digest/sha1"
18 require "digest/sha1"
19
19
20 class User < ActiveRecord::Base
20 class User < ActiveRecord::Base
21
22 class OnTheFlyCreationFailure < Exception; end
23
21 # Account statuses
24 # Account statuses
22 STATUS_ANONYMOUS = 0
25 STATUS_ANONYMOUS = 0
23 STATUS_ACTIVE = 1
26 STATUS_ACTIVE = 1
@@ -105,15 +108,17 class User < ActiveRecord::Base
105 onthefly.language = Setting.default_language
108 onthefly.language = Setting.default_language
106 if onthefly.save
109 if onthefly.save
107 user = find(:first, :conditions => ["login=?", login])
110 user = find(:first, :conditions => ["login=?", login])
108 logger.info("User '#{user.login}' created on the fly.") if logger
111 logger.info("User '#{user.login}' created from the LDAP") if logger
112 else
113 logger.error("User '#{onthefly.login}' found in LDAP but could not be created (#{onthefly.errors.full_messages.join(', ')})") if logger
114 raise OnTheFlyCreationFailure.new
109 end
115 end
110 end
116 end
111 end
117 end
112 user.update_attribute(:last_login_on, Time.now) if user
118 user.update_attribute(:last_login_on, Time.now) if user
113 user
119 user
114
120 rescue => text
115 rescue => text
121 raise text
116 raise text
117 end
122 end
118
123
119 # Return user's full name for display
124 # Return user's full name for display
General Comments 0
You need to be logged in to leave comments. Login now