Refactoring

This commit is contained in:
Bubka
2020-01-25 18:22:45 +01:00
parent ffaef86909
commit 2233f1119b
2 changed files with 25 additions and 33 deletions

View File

@@ -15,15 +15,10 @@ class OTP
* @param \App\TwoFAccount $twofaccount
* @return an array that represent the totp code
*/
public static function get($uri)
public static function generate($uri)
{
try {
$otp = Factory::loadFromProvisioningUri($uri);
}
catch (AssertionFailedException $exception) {
return false;
}
$otp = $this->get($uri);
if( get_class($otp) === 'OTPHP\TOTP' ) {
@@ -58,7 +53,27 @@ class OTP
return $hotp;
}
}
/**
* check if the provided uri is a valid OTP uri
*
* @param \App\TwoFAccount $twofaccount
* @return \Illuminate\Http\Response
*/
public static function get(String $uri) {
try {
return Factory::loadFromProvisioningUri($uri);
}
catch (AssertionFailedException $exception) {
$error = \Illuminate\Validation\ValidationException::withMessages([
'qrcode' => __('errors.response.no_valid_totp')
]);
throw $error;
}
}