From f10b3b7cdb2f3ca86028a9c82faf9d56ca5f20ef Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 24 May 2016 01:51:47 -0700 Subject: [PATCH] Fix for license importer --- app/Console/Commands/LicenseImportCommand.php | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/app/Console/Commands/LicenseImportCommand.php b/app/Console/Commands/LicenseImportCommand.php index 7c2118e198..7cff92fd1c 100644 --- a/app/Console/Commands/LicenseImportCommand.php +++ b/app/Console/Commands/LicenseImportCommand.php @@ -5,6 +5,7 @@ use Illuminate\Console\Command; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputArgument; use League\Csv\Reader; +use App\Models\User; class LicenseImportCommand extends Command { @@ -240,26 +241,24 @@ class LicenseImportCommand extends Command { if ($user = User::where('username', $user_username)->whereNotNull('username')->first()) { $this->comment('User '.$user_username.' already exists'); } else { - // Create the user - $user = Sentry::createUser(array( - 'first_name' => $first_name, - 'last_name' => $last_name, - 'email' => $user_email, - 'username' => $user_username, - 'password' => substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 10), - 'activated' => true, - 'permissions' => array( - 'admin' => 0, - 'user' => 1, - ), - 'notes' => 'User importerd through license importer' - )); - // Find the group using the group id - $userGroup = Sentry::findGroupById(3); + $user = new \App\Models\User; + $password = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 20); + + $user->first_name = $first_name; + $user->last_name = $last_name; + $user->username = $user_username; + $user->email = $user_email; + $user->permissions = '{user":1}'; + $user->password = bcrypt($password); + $user->activated = 1; + if ($user->save()) { + $this->comment('User '.$first_name.' created'); + } else { + $this->error('ERROR CREATING User '.$first_name.' '.$last_name); + $this->error($user->getErrors()); + } - // Assign the group to the user - $user->addGroup($userGroup); $this->comment('User '.$first_name.' created'); } } else {