F
Filament2w ago
Adel

redirect new registered users to additional registration wizard

I want new registered users to continoue registration prcess by redirecting them to a wizard where they can provide additional important information. this will occue only once. I tried to use middleware redirect but i am getting too many redirects error!
Solution:
You also have to check if you are on that route otherwise it’s an endless loop.
Jump to solution
3 Replies
Adel
AdelOP2w ago
the targeted user is logged in users
<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;

class CreateTreeIfNotExists
{
/**
* Handle an incoming request.
*
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle(Request $request, Closure $next): Response
{
dump('create tree if not exists');

if(auth()->check() && !auth()->user()->trees()->exists()) {
return redirect()->route('filament.dashboard.pages.trees.wizard');
}

return $next($request);
}
}
<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;

class CreateTreeIfNotExists
{
/**
* Handle an incoming request.
*
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle(Request $request, Closure $next): Response
{
dump('create tree if not exists');

if(auth()->check() && !auth()->user()->trees()->exists()) {
return redirect()->route('filament.dashboard.pages.trees.wizard');
}

return $next($request);
}
}
Solution
awcodes
awcodes2w ago
You also have to check if you are on that route otherwise it’s an endless loop.
Adel
AdelOP2w ago
Yea this was the issue. Thanks @awcodes
Want results from more Discord servers?
Add your server