refactor: Refactor PasskeysController and Passkey model
- Remove unused `use` statements and imports in `PasskeysController.php` and `Passkey.php` - Improve code cleanliness and remove unnecessary dependencies
This commit is contained in:
parent
4253764f39
commit
483b3016ba
2 changed files with 5 additions and 8 deletions
|
@ -16,8 +16,6 @@ use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\App;
|
use Illuminate\Support\Facades\App;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Hash;
|
|
||||||
use Illuminate\Support\Facades\Validator;
|
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
use ParagonIE\ConstantTime\Base64UrlSafe;
|
use ParagonIE\ConstantTime\Base64UrlSafe;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
@ -121,12 +119,12 @@ class PasskeysController extends Controller
|
||||||
|
|
||||||
$attestationSupportManager = AttestationStatementSupportManager::create();
|
$attestationSupportManager = AttestationStatementSupportManager::create();
|
||||||
$attestationSupportManager->add(NoneAttestationStatementSupport::create());
|
$attestationSupportManager->add(NoneAttestationStatementSupport::create());
|
||||||
$attestationObjectLoader = AttestationObjectLoader::create($attestationSupportManager);
|
$attestationObjectLoader = AttestationObjectLoader::create($attestationSupportManager);
|
||||||
$publicKeyCredentialLoader = PublicKeyCredentialLoader::create($attestationObjectLoader);
|
$publicKeyCredentialLoader = PublicKeyCredentialLoader::create($attestationObjectLoader);
|
||||||
|
|
||||||
$publicKeyCredential = $publicKeyCredentialLoader->load(json_encode($request->all(), JSON_THROW_ON_ERROR));
|
$publicKeyCredential = $publicKeyCredentialLoader->load(json_encode($request->all(), JSON_THROW_ON_ERROR));
|
||||||
|
|
||||||
if (!$publicKeyCredential->response instanceof AuthenticatorAttestationResponse) {
|
if (! $publicKeyCredential->response instanceof AuthenticatorAttestationResponse) {
|
||||||
throw new WebAuthnException('Invalid response type');
|
throw new WebAuthnException('Invalid response type');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,12 +191,12 @@ class PasskeysController extends Controller
|
||||||
|
|
||||||
$attestationSupportManager = AttestationStatementSupportManager::create();
|
$attestationSupportManager = AttestationStatementSupportManager::create();
|
||||||
$attestationSupportManager->add(NoneAttestationStatementSupport::create());
|
$attestationSupportManager->add(NoneAttestationStatementSupport::create());
|
||||||
$attestationObjectLoader = AttestationObjectLoader::create($attestationSupportManager);
|
$attestationObjectLoader = AttestationObjectLoader::create($attestationSupportManager);
|
||||||
$publicKeyCredentialLoader = PublicKeyCredentialLoader::create($attestationObjectLoader);
|
$publicKeyCredentialLoader = PublicKeyCredentialLoader::create($attestationObjectLoader);
|
||||||
|
|
||||||
$publicKeyCredential = $publicKeyCredentialLoader->load(json_encode($request->all(), JSON_THROW_ON_ERROR));
|
$publicKeyCredential = $publicKeyCredentialLoader->load(json_encode($request->all(), JSON_THROW_ON_ERROR));
|
||||||
|
|
||||||
if (!$publicKeyCredential->response instanceof AuthenticatorAssertionResponse) {
|
if (! $publicKeyCredential->response instanceof AuthenticatorAssertionResponse) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'success' => false,
|
'success' => false,
|
||||||
'message' => 'Invalid response type',
|
'message' => 'Invalid response type',
|
||||||
|
@ -206,7 +204,7 @@ class PasskeysController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
$passkey = Passkey::firstWhere('passkey_id', $publicKeyCredential->id);
|
$passkey = Passkey::firstWhere('passkey_id', $publicKeyCredential->id);
|
||||||
if (!$passkey) {
|
if (! $passkey) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'success' => false,
|
'success' => false,
|
||||||
'message' => 'Passkey not found',
|
'message' => 'Passkey not found',
|
||||||
|
|
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
Loading…
Add table
Reference in a new issue