Skip to content

A free open source IT asset/license management system

Valo/ch37/cannot log in with generated password from (#6655)

Ivan Nieto9ac40f705ccc
diff --git a/app/Importer/Importer.php b/app/Importer/Importer.php
index d8b5305033..ca3b7593f4 100644
--- a/app/Importer/Importer.php
+++ b/app/Importer/Importer.php
@@ -440,4 +440,13 @@ abstract class Importer
return $this;
}
+
+ public function fetchHumanBoolean($value)
+ {
+ if (($value =='1') || (strtolower($value) =='true') || (strtolower($value) =='yes'))
+ {
+ return '1';
+ }
+ return '0';
+ }
}
diff --git a/app/Importer/UserImporter.php b/app/Importer/UserImporter.php
index 4ab7cb4c20..e9be1946fd 100644
--- a/app/Importer/UserImporter.php
+++ b/app/Importer/UserImporter.php
@@ -38,7 +38,7 @@ class UserImporter extends ItemImporter
$this->item['email'] = $this->findCsvMatch($row, 'email');
$this->item['phone'] = $this->findCsvMatch($row, 'phone_number');
$this->item['jobtitle'] = $this->findCsvMatch($row, 'jobtitle');
- $this->item['activated'] = $this->findCsvMatch($row, 'activated');
+ $this->item['activated'] = $this->fetchHumanBoolean($this->findCsvMatch($row, 'activated'));
$this->item['employee_num'] = $this->findCsvMatch($row, 'employee_num');
$this->item['department_id'] = $this->createOrFetchDepartment($this->findCsvMatch($row, 'department'));
$this->item['manager_id'] = $this->fetchManager($this->findCsvMatch($row, 'manager_first_name'), $this->findCsvMatch($row, 'manager_last_name'));
@@ -60,11 +60,12 @@ class UserImporter extends ItemImporter
}
// This needs to be applied after the update logic, otherwise we'll overwrite user passwords
// Issue #5408
- $this->item['password'] = $this->tempPassword;
+ $this->item['password'] = bcrypt($this->tempPassword);
$this->log("No matching user, creating one");
$user = new User();
$user->fill($this->sanitizeItemForStoring($user));
+
if ($user->save()) {
// $user->logCreate('Imported using CSV Importer');
$this->log("User " . $this->item["name"] . ' was created');