Closed murrant closed 3 years ago
Hi @murrant!
This isn't actually a bug with LdapRecord-Laravel -- this is because Laravel Jetstream assumes the creation of new users will occur through it's interface, which executes the CreateNewUser
action that is published into the app folder, thereby creating the default team if it does not exist:
https://github.com/laravel/jetstream/blob/2.x/stubs/app/Actions/Fortify/CreateNewUserWithTeams.php
Since this action is published (i.e. cannot be assumed to be the same in every Laravel Jetstream application) and validates data for user creation, we cannot utilize it.
I would suggest simply listening for the LdapRecord-Laravel Imported
event and then creating the team there, as it's done inside the CreateNewUser
action:
https://github.com/DirectoryTree/LdapRecord-Laravel/blob/master/src/Events/Import/Imported.php
public function handle(Imported $event)
{
$user = $event->eloquent;
$user->ownedTeams()->save(Team::forceCreate([
'user_id' => $user->id,
'name' => explode(' ', $user->name, 2)[0]."'s Team",
'personal_team' => true,
]));
}
Perhaps this is just a missing documentation issue then :) Thanks for the detailed response.
You're right -- this should be added to the docs! 👍
I'll re-open this issue and then close it again once I've updated them.
Great! Thanks @stevebauman
Environment (please complete the following information):
Describe the bug: When using Fortify to authenticate with LdapRecord, the initial user creation does not create the default team "[User]'s Team". It is assumed this team is created so you get errors because the user has no team.