28 lines
868 B
PHP
28 lines
868 B
PHP
<?php
|
|
|
|
namespace App\Http\Responses;
|
|
|
|
use App\Services\AuthEntryPointService;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Laravel\Fortify\Contracts\TwoFactorLoginResponse as TwoFactorLoginResponseContract;
|
|
use Laravel\Fortify\Fortify;
|
|
|
|
class TwoFactorLoginResponse implements TwoFactorLoginResponseContract
|
|
{
|
|
public function __construct(private readonly AuthEntryPointService $authEntryPointService) {}
|
|
|
|
/**
|
|
* Create an HTTP response that represents the object.
|
|
*/
|
|
public function toResponse($request): JsonResponse|RedirectResponse
|
|
{
|
|
session()->flash('show_encryption_prompt', true);
|
|
$this->authEntryPointService->queueReturningUserCookie();
|
|
|
|
return $request->wantsJson()
|
|
? new JsonResponse('', 204)
|
|
: redirect()->intended(Fortify::redirects('login'));
|
|
}
|
|
}
|