Ldaprecord-laravel: [Bug] When using Jetstream with Teams, default team is not created.

Created on 4 Jun 2021  路  5Comments  路  Source: DirectoryTree/LdapRecord-Laravel

Environment (please complete the following information):

  • LDAP Server Type: ActiveDirectory
  • PHP Version: 8.0.6

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.

enhancement question

All 5 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ellisonpatterson picture ellisonpatterson  路  9Comments

kruiz122893 picture kruiz122893  路  5Comments

AlexH269 picture AlexH269  路  4Comments

kruiz122893 picture kruiz122893  路  5Comments

satyakresna picture satyakresna  路  7Comments