From 2d0df24ef37fc912d7523d85a72da0c5ffe27fe3 Mon Sep 17 00:00:00 2001 From: Daniel Meltzer Date: Fri, 3 Aug 2018 19:35:13 -0400 Subject: [PATCH] Check for an existing username before getting creative. Fixes #6016 (#6039) --- app/Importer/Importer.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/Importer/Importer.php b/app/Importer/Importer.php index 88b3888022..c4ae003cc1 100644 --- a/app/Importer/Importer.php +++ b/app/Importer/Importer.php @@ -272,6 +272,13 @@ abstract class Importer 'email' => $this->findCsvMatch($row, "email"), 'username' => $this->findCsvMatch($row, "username") ]; + + // Maybe we're lucky and the user already exists. + if($user = User::where('username', $user_array['username'])->first()) { + $this->log('User '.$user_array['username'].' already exists'); + return $user; + } + // If the full name is empty, bail out--we need this to extract first name (at the very least) if(empty($user_array['full_name'])) { $this->log('Insufficient user data provided (Full name is required)- skipping user creation, just adding asset');