Files
2FAuth/app/Http/Requests/WebauthnAttestationRequest.php
2025-06-18 09:02:23 +02:00

32 lines
880 B
PHP

<?php
namespace App\Http\Requests;
use Illuminate\Support\Facades\Gate;
use Laragear\WebAuthn\Contracts\WebAuthnAuthenticatable;
use Laragear\WebAuthn\Http\Requests\AttestationRequest;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
class WebauthnAttestationRequest extends AttestationRequest
{
/**
* Handle a failed authorization attempt.
*
* @return void
*
* @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
*/
protected function failedAuthorization()
{
throw new AccessDeniedHttpException(__('errors.unsupported_with_sso_only'));
}
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(?WebAuthnAuthenticatable $user) : bool
{
return (bool) $user && Gate::allows('manage-webauthn-credentials');
}
}