Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Commands/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,12 @@ private function create(?string $username = null, ?string $email = null): void
$userModel->save($user);
$this->write('User "' . $username . '" created', 'green');
}

// Add to default group
$user = $userModel->findById($userModel->getInsertID());
$userModel->addToDefaultGroup($user);

$this->write('The user is added to the default group.', 'green');
}

/**
Expand Down
5 changes: 5 additions & 0 deletions tests/Commands/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace Tests\Commands;

use CodeIgniter\Shield\Commands\User;
use CodeIgniter\Shield\Config\AuthGroups;
use CodeIgniter\Shield\Entities\User as UserEntity;
use CodeIgniter\Shield\Models\UserModel;
use CodeIgniter\Shield\Test\MockInputOutput;
Expand Down Expand Up @@ -93,6 +94,10 @@ public function testCreate(): void
'id' => $user->id,
'active' => 0,
]);
$this->seeInDatabase($this->tables['groups_users'], [
'user_id' => $user->id,
'group' => config(AuthGroups::class)->defaultGroup,
]);
}

public function testCreateNotUniqueName(): void
Expand Down