mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-04-15 21:18:25 +02:00
Add new exceptions
This commit is contained in:
parent
4c2c7f95ac
commit
f7fcef77f1
@ -53,10 +53,20 @@ public function render($request, Throwable $exception)
|
|||||||
return response()->json([
|
return response()->json([
|
||||||
'message' => str_replace('App\\', '', $exception->getModel()).' not found'], 404);
|
'message' => str_replace('App\\', '', $exception->getModel()).' not found'], 404);
|
||||||
}
|
}
|
||||||
|
if ($exception instanceof InvalidOtpParameterException) {
|
||||||
|
return response()->json([
|
||||||
|
'message' => 'invalid OTP parameters',
|
||||||
|
'reason' => [$exception->getMessage()]
|
||||||
|
], 400);
|
||||||
|
}
|
||||||
if ($exception instanceof InvalidQrCodeException) {
|
if ($exception instanceof InvalidQrCodeException) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'message' => 'not a valid QR code'], 400);
|
'message' => 'not a valid QR code'], 400);
|
||||||
}
|
}
|
||||||
|
if ($exception instanceof InvalidSecretException) {
|
||||||
|
return response()->json([
|
||||||
|
'message' => 'not a valid base32 encoded secret'], 400);
|
||||||
|
}
|
||||||
|
|
||||||
return parent::render($request, $exception);
|
return parent::render($request, $exception);
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class UnsupportedOtpType.
|
* Class InvalidQrCodeException.
|
||||||
*
|
*
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*/
|
*/
|
||||||
|
14
app/Exceptions/InvalidSecretException.php
Normal file
14
app/Exceptions/InvalidSecretException.php
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exceptions;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class InvalidSecretException.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
class InvalidSecretException extends Exception
|
||||||
|
{
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user