feat: show identity match hint on registration success page
When a pending identity match is detected after volunteer registration, the API now returns has_existing_account in the response. The success page shows a login suggestion card so the volunteer can link their registration to their existing account. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\Api\V1;
|
||||
|
||||
use App\Enums\IdentityMatchStatus;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Api\V1\VolunteerRegistrationRequest;
|
||||
use App\Http\Resources\Api\V1\PersonResource;
|
||||
use App\Models\Event;
|
||||
use App\Models\PersonIdentityMatch;
|
||||
use App\Services\VolunteerRegistrationService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
final class VolunteerRegistrationController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private readonly VolunteerRegistrationService $registrationService,
|
||||
) {}
|
||||
|
||||
public function __invoke(VolunteerRegistrationRequest $request, Event $event): JsonResponse
|
||||
{
|
||||
$user = auth('sanctum')->user();
|
||||
|
||||
$person = $this->registrationService->register(
|
||||
$event,
|
||||
$request->validated(),
|
||||
$user
|
||||
);
|
||||
|
||||
$person->load('crowdType');
|
||||
|
||||
$hasExistingAccount = PersonIdentityMatch::where('person_id', $person->id)
|
||||
->where('status', IdentityMatchStatus::PENDING)
|
||||
->exists();
|
||||
|
||||
$responseData = [
|
||||
'person' => new PersonResource($person),
|
||||
'has_existing_account' => $hasExistingAccount,
|
||||
];
|
||||
|
||||
if ($person->wasRecentlyCreated) {
|
||||
return $this->created($responseData);
|
||||
}
|
||||
|
||||
return $this->success($responseData);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user