Refactor VerificationOtpAuthentication to handle database operation exceptions when retrieving session
https://github.com/nosial/Socialbox-PHP/issues/78
This commit is contained in:
parent
a433ad2593
commit
76a343a36d
1 changed files with 10 additions and 1 deletions
|
@ -8,6 +8,7 @@
|
||||||
use Socialbox\Enums\Flags\SessionFlags;
|
use Socialbox\Enums\Flags\SessionFlags;
|
||||||
use Socialbox\Enums\StandardError;
|
use Socialbox\Enums\StandardError;
|
||||||
use Socialbox\Exceptions\CryptographyException;
|
use Socialbox\Exceptions\CryptographyException;
|
||||||
|
use Socialbox\Exceptions\DatabaseOperationException;
|
||||||
use Socialbox\Exceptions\Standard\InvalidRpcArgumentException;
|
use Socialbox\Exceptions\Standard\InvalidRpcArgumentException;
|
||||||
use Socialbox\Exceptions\Standard\MissingRpcArgumentException;
|
use Socialbox\Exceptions\Standard\MissingRpcArgumentException;
|
||||||
use Socialbox\Exceptions\Standard\StandardRpcException;
|
use Socialbox\Exceptions\Standard\StandardRpcException;
|
||||||
|
@ -35,7 +36,15 @@
|
||||||
throw new InvalidRpcArgumentException('code', 'Invalid OTP code length');
|
throw new InvalidRpcArgumentException('code', 'Invalid OTP code length');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
$session = $request->getSession();
|
$session = $request->getSession();
|
||||||
|
}
|
||||||
|
catch (DatabaseOperationException $e)
|
||||||
|
{
|
||||||
|
throw new StandardRpcException('An error occurred while trying to get the session', StandardError::INTERNAL_SERVER_ERROR, $e);
|
||||||
|
}
|
||||||
|
|
||||||
if(!$session->flagExists(SessionFlags::VER_OTP))
|
if(!$session->flagExists(SessionFlags::VER_OTP))
|
||||||
{
|
{
|
||||||
return $rpcRequest->produceError(StandardError::METHOD_NOT_ALLOWED, 'One Time Password verification is not required at this time');
|
return $rpcRequest->produceError(StandardError::METHOD_NOT_ALLOWED, 'One Time Password verification is not required at this time');
|
||||||
|
|
Loading…
Add table
Reference in a new issue