Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Hedam's avatar

Don't force team registration

Hi

My Spark installation should not require users to register a team. Our application is built on the idea that everyone should have a team, but a few features is available without.

Is there a way to allow users to register without teams? I've tried changing the views, but the whole authentication driver behind spark still requires the team field, and I'm not quite sure how much I "may" change in the spark folder without saying goodbye to every upcoming update.

Thank you in advance.

0 likes
6 replies
EventFellows's avatar

I'd also be very interested to get this answered without breaking future updates...

Here is what I found so far:

  • the concept of a team is entirely optional in spark (users can delete a team after the initial cration and everyhting will work normally) - only the validation during registration breaks it
  • unfortunately 'required' is hardcoded in validation during registraion in vendor\laravel\spark\src\Interactions\Auth\CreateUser.php

as follows:

    public function validator($request)
    {
        $validator = $this->baseValidator($request);

        $validator->sometimes('team', 'required|max:255', function ($input) {
            return Spark::usesTeams() && ! isset($input['invitation']);
        });

        return $validator;

If you remove the 'required' you are done, but this might break any future updates - which is exactly the tricky point...

EDIT: there is also a middleware reminding/ redirecting people to create a team if they have none, but it can be disabled easily.

pstephan1187's avatar

Extend the original CreateUser class and override the validator method. Then in your AppServiceProviders register method, add this line:

app()->bind('Laravel\Spark\Contracts\Interactions\Auth\CreateUser', YourNewCreateUserClass::class, true);

This won't keep the team from being created, but will in actuality create a nameless team.

2 likes
Hedam's avatar

An optimal approach would be to not have any breaking changes. Creating a nameless team wouldn't make sense either.

Kairu's avatar

Bit of a necrobump but I figured out a workaround after I asked the same question on /r/laravel: https://www.reddit.com/r/laravel/comments/4l3iyo/adapting_spark_teams_to_fit_my_use_case/

You need to copy Register and CreateUser classes from Laravel\Spark\Interactions\Auth and remove lines:

  • Register: 58
  • CreateUser: 20-22

You then need to bind your new interactions to the container. I did mine in my SparkServiceProvider@register:

$this->app->bind('Laravel\Spark\Contracts\Interactions\Auth\Register', Register::class);
$this->app->bind('Laravel\Spark\Contracts\Interactions\Auth\CreateUser', CreateUser::class);

Remove the input field in the common registration template. Now you need to remove the hasTeam middleware from your own RouteServiceProvider to prevent the missing-team redirect after registering.

I also have my own user creator/validator classes swapped so I'm not sure if you'll need to do that or not to remove any teamname required validation.

@Hedam @EventFellows

3 likes
plushyObject's avatar

If anyone happens to come across this because they are seeing the missing-team view and url, this is because there is the hasTeam middleware being passed in your RouteServiceProvider. You can just remove that from the middleware array for the group:

    protected function mapWebRoutes(Router $router)
    {
        $router->group([
            'namespace' => $this->namespace, 'middleware' => ['web', 'hasTeam'],
        ], function ($router) {
            require base_path('routes/web.php');
        });
    }

This is in 5.4 again in the App\Providers\RouteServiceProvider

4 likes

Please or to participate in this conversation.