Use app()->getLocale() to determine imported user’s language

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2024-07-13 15:15:44 +01:00
parent eed253bd2f
commit f91ad6b2db
2 changed files with 4 additions and 1 deletions

View file

@ -232,6 +232,7 @@ class LdapSync extends Command
$item['department'] = $results[$i][$ldap_result_dept][0] ?? ''; $item['department'] = $results[$i][$ldap_result_dept][0] ?? '';
$item['manager'] = $results[$i][$ldap_result_manager][0] ?? ''; $item['manager'] = $results[$i][$ldap_result_manager][0] ?? '';
$item['location'] = $results[$i][$ldap_result_location][0] ?? ''; $item['location'] = $results[$i][$ldap_result_location][0] ?? '';
$item['locale'] = app()->getLocale();
// ONLY if you are using the "ldap_location" option *AND* you have an actual result // ONLY if you are using the "ldap_location" option *AND* you have an actual result
if ($ldap_result_location && $item['location']) { if ($ldap_result_location && $item['location']) {

View file

@ -229,6 +229,7 @@ class Ldap extends Model
$item['department'] = $ldapattributes[$ldap_result_dept][0] ?? ''; $item['department'] = $ldapattributes[$ldap_result_dept][0] ?? '';
$item['manager'] = $ldapattributes[$ldap_result_manager][0] ?? ''; $item['manager'] = $ldapattributes[$ldap_result_manager][0] ?? '';
$item['location'] = $ldapattributes[$ldap_result_location][0] ?? ''; $item['location'] = $ldapattributes[$ldap_result_location][0] ?? '';
$item['locale'] = app()->getLocale();
return $item; return $item;
} }
@ -239,7 +240,7 @@ class Ldap extends Model
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v3.0] * @since [v3.0]
* @param $ldapatttibutes * @param $ldapatttibutes
* @return array|bool * @return User | bool
*/ */
public static function createUserFromLdap($ldapatttibutes, $password) public static function createUserFromLdap($ldapatttibutes, $password)
{ {
@ -252,6 +253,7 @@ class Ldap extends Model
$user->last_name = $item['lastname']; $user->last_name = $item['lastname'];
$user->username = $item['username']; $user->username = $item['username'];
$user->email = $item['email']; $user->email = $item['email'];
$user->locale = $item['locale'];
$user->password = $user->noPassword(); $user->password = $user->noPassword();
if (Setting::getSettings()->ldap_pw_sync == '1') { if (Setting::getSettings()->ldap_pw_sync == '1') {