Require Login/Register to Execute Action

I have a public page (Livewire component) with a Filament form:
class CreateFirstBooking extends SimplePage implements HasForms
{
use InteractsWithForms;

public ?array $data = [];

// ...

public function form(Form $form): Form
{
// public form...
}

// ...

public function submit()
{
// exec code after the user logs in or registers
}
}
class CreateFirstBooking extends SimplePage implements HasForms
{
use InteractsWithForms;

public ?array $data = [];

// ...

public function form(Form $form): Form
{
// public form...
}

// ...

public function submit()
{
// exec code after the user logs in or registers
}
}
I wish to submit this form and execute some code after the user logs in or registers... The flow would be: - Fill out the form - Click the submit button - Register or Login - Use that user recently created or logged user to execute some code Is that possible using the Filament login/register form?
7 Replies
LeandroFerreira
LeandroFerreira5mo ago
maybe a custom middleware to redirect the user to this form after login/register?
Bruno Silva
Bruno SilvaOP5mo ago
I'm not sure what to do, but I wanted the user to fill the form before the login, and then create everything that they filled after the login or register but I'll check if I can do it with middlewares
awcodes
awcodes5mo ago
It might be easier to override the existing Login class unless you absolutely need full customization.
Bruno Silva
Bruno SilvaOP5mo ago
this form is for something else, to gather data to create a reservation and a vehicle for that user.
awcodes
awcodes5mo ago
Fair enough. In that case I agree with Leandro.
Bruno Silva
Bruno SilvaOP5mo ago
don't know if this is the best solution, but I did: In the public page:
public function submit()
{
$data = $this->form->getState();

session(['first_booking_data' => $data]);

return redirect()->route('filament.client.auth.register');
}
public function submit()
{
$data = $this->form->getState();

session(['first_booking_data' => $data]);

return redirect()->route('filament.client.auth.register');
}
Then created a listener that listen to Filament\Events\Auth\Registered, to handle the processsing of that booking
awcodes
awcodes5mo ago
If it works, it’s not wrong.
Want results from more Discord servers?
Add your server