-
Notifications
You must be signed in to change notification settings - Fork 806
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow personal teams to be optional #910
Allow personal teams to be optional #910
Conversation
Thanks for your pull request to Laravel! Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include. If possible, please consider releasing your code as a package so that the community can still take advantage of your contributions! If you feel absolutely certain that this code corrects a bug in the framework, please "@" mention me in a follow-up comment with further explanation so that GitHub will send me a notification of your response. |
@taylorotwell the PR to me seemed high valuable, bringing in a config options just like you'd expect in fortify. Despite that the test could be extended rather then skipping if there is no personal team desired, it should still be a first party solution and not a community package. Disabling a personal team isn't much of a change code wise, most that was done was replacing wether the team is desired over a hardcoded true. I'd love if you could reconsider checking this PR. If necessary I am more than willing to help OP to write the tests for the non-personal-team option. |
Just going to chime in and say too, across a variety of SaaS apps, this is the most common use case. Where someone is a team owner and wants to invite a 'teammate', without creating their own team/tenant at the same time. If this decision can be re-considered it would make Jetstream much more versatile :) |
It's kind of restricting if you can't disable personal teams. |
I think this needs to be reconsidered. I have been working on 5 or 6 websites now that use jetstream and only one of them have required a personal team, while the rest of them only needed to have teams optionally. in the end, for them, we ended up just disabling teams and adding in our own integration but it would be 1000x better having an optional team without personal teams in jetstream natively. |
Chiming in as others have said, personal teams make no sense and I'd welcome an explanation as to why they are mandatory. It is a poor design decision that has now got out hand? I've never come across a system that works in this manner. If I create a team and ask people to join, they join my team directly. |
@taylorotwell if this PR isn't going to be merged then can we get this feature in the near future? |
I just implemented similar case by changing Fortify actions provided by Jetstream, in my case users can only be created through a valid invitation. I highly think that having Personal team to be optional is needed as explained by top comments. // in App\Actions\Fortify\CreateNewUser
use App\Models\TeamInvitation;
use Laravel\Jetstream\Contracts\AddsTeamMembers;
class CreateNewUser implements CreatesNewUsers
{
public function create(array $input)
{
Validator::make($input, [
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users', 'exists:team_invitations'],
'password' => $this->passwordRules(),
'terms' => Jetstream::hasTermsAndPrivacyPolicyFeature() ? ['required', 'accepted'] : '',
],
[
'email.exists' => 'Can only register using invited email.',
])->validate();
return DB::transaction(function () use ($input) {
return tap(User::create([
'name' => $input['name'],
'email' => $input['email'],
'password' => Hash::make($input['password']),
]), function (User $user) {
// Disable creating personal team for each user
//$this->createTeam($user);
$invitation = TeamInvitation::where('email', $user->email)->first();
$this->assignTeam($user, $invitation);
});
});
}
protected function assignTeam(User $user, TeamInvitation $invitation)
{
app(AddsTeamMembers::class)->add(
$invitation->team->owner,
$invitation->team,
$invitation->email,
$invitation->role
);
$user->current_team_id = $invitation->team_id;
$user->save();
}
} |
The link to the article mentioned above has moved to: https://npratley.net/disabling-personal-teams-in-laravel-8-and-jetstream-1fd083593e08/ |
The PR makes personal teams still default on a new install but has the option of disabling. This will allow a broader use of this package where registering a user doesn't create a personal team. This behavior is controlled by the
config/jetstream.php
file:The default behavior on a new install is unchanged. When enabled, personal teams still cannot be deleted. When disabled, no personal team is created at the time of user registration and allows the user to not be a member of any team. Team creation is still controlled by the
create
team gate in both cases. Both inertia and livewire templates have been updated and all tests pass.The installer should decide during activation of the teams feature if this option should be enabled or disabled.