From 9ac40f705ccc830d7a2759bb2e689e2ebefe91e1 Mon Sep 17 00:00:00 2001 From: Ivan Nieto Date: Thu, 31 Jan 2019 21:58:54 -0600 Subject: [PATCH] Valo/ch37/cannot log in with generated password from (#6655) * Cannot log in with generated password from [ch37] * Cannot log in with generated password from [ch37]. Light cleanup * Added the fetchHumanBoolean() method. * Cleaning up the ternary --- app/Importer/Importer.php | 9 +++++++++ app/Importer/UserImporter.php | 5 +++-- 2 files changed, 12 insertions(+), 2 deletions(-) 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');