Fixed issue #429, user.preferences['locale'] not initialized at user creation.

This commit is contained in:
Jens Pfeifer 2017-02-06 14:06:54 +00:00
parent 1c7278d8be
commit 777dce4c87

View file

@ -38,7 +38,7 @@ class User < ApplicationModel
include User::SearchIndex
before_validation :check_name, :check_email, :check_login, :ensure_password
before_create :check_preferences_default, :validate_roles, :domain_based_assignment
before_create :check_preferences_default, :validate_roles, :domain_based_assignment, :set_locale
before_update :check_preferences_default, :validate_roles
after_create :avatar_for_email_check
after_update :avatar_for_email_check
@ -881,6 +881,18 @@ returns
end
end
# sets locale of the user
def set_locale
# set the user's locale to the one of the "executing" user
return if !UserInfo.current_user_id
user = User.find_by( id: UserInfo.current_user_id )
return if !user
return if !user.preferences[:locale]
self.preferences[:locale] = user.preferences[:locale]
end
def avatar_for_email_check
return if email.blank?
return if email !~ /@/