Override ->registration() in PanelProvider
Anyone how to override this is v3? I don't want to automatically logging in the user after creation.
1 Reply
For anyone also wondering I made it work but I'm not sure if this is correct. :
I have just remove the
<?php
namespace App\Http\Controllers\Auth;
use Illuminate\Auth\Events\Registered;
use Filament\Notifications\Notification;
use Filament\Pages\Auth\Register as AuthRegister;
use Filament\Http\Responses\Auth\Contracts\RegistrationResponse;
use DanHarrin\LivewireRateLimiting\Exceptions\TooManyRequestsException;
/**
* @property Form $form
*/
class Register extends AuthRegister
{
public function register(): ?RegistrationResponse
{
try {
$this->rateLimit(2);
} catch (TooManyRequestsException $exception) {
Notification::make()
->title(__('filament-panels::pages/auth/register.notifications.throttled.title', [
'seconds' => $exception->secondsUntilAvailable,
'minutes' => ceil($exception->secondsUntilAvailable / 60),
]))
->body(array_key_exists('body', __('filament-panels::pages/auth/register.notifications.throttled') ?: []) ? __('filament-panels::pages/auth/register.notifications.throttled.body', [
'seconds' => $exception->secondsUntilAvailable,
'minutes' => ceil($exception->secondsUntilAvailable / 60),
]) : null)
->danger()
->send();
return null;
}
$data = $this->form->getState();
$user = $this->getUserModel()::create($data);
app()->bind(
\Illuminate\Auth\Listeners\SendEmailVerificationNotification::class,
\Filament\Listeners\Auth\SendEmailVerificationNotification::class,
);
event(new Registered($user));
session()->regenerate();
return app(RegistrationResponse::class);
}
}
<?php
namespace App\Http\Controllers\Auth;
use Illuminate\Auth\Events\Registered;
use Filament\Notifications\Notification;
use Filament\Pages\Auth\Register as AuthRegister;
use Filament\Http\Responses\Auth\Contracts\RegistrationResponse;
use DanHarrin\LivewireRateLimiting\Exceptions\TooManyRequestsException;
/**
* @property Form $form
*/
class Register extends AuthRegister
{
public function register(): ?RegistrationResponse
{
try {
$this->rateLimit(2);
} catch (TooManyRequestsException $exception) {
Notification::make()
->title(__('filament-panels::pages/auth/register.notifications.throttled.title', [
'seconds' => $exception->secondsUntilAvailable,
'minutes' => ceil($exception->secondsUntilAvailable / 60),
]))
->body(array_key_exists('body', __('filament-panels::pages/auth/register.notifications.throttled') ?: []) ? __('filament-panels::pages/auth/register.notifications.throttled.body', [
'seconds' => $exception->secondsUntilAvailable,
'minutes' => ceil($exception->secondsUntilAvailable / 60),
]) : null)
->danger()
->send();
return null;
}
$data = $this->form->getState();
$user = $this->getUserModel()::create($data);
app()->bind(
\Illuminate\Auth\Listeners\SendEmailVerificationNotification::class,
\Filament\Listeners\Auth\SendEmailVerificationNotification::class,
);
event(new Registered($user));
session()->regenerate();
return app(RegistrationResponse::class);
}
}
return $panel
->default()
->id('admin')
->path('admin')
->login()
->registration(Register::class)
return $panel
->default()
->id('admin')
->path('admin')
->login()
->registration(Register::class)
Filament::auth()->login($user);