diff --git a/app/Http/Controllers/TwoFAccountController.php b/app/Http/Controllers/TwoFAccountController.php index 25d27934..816b73b3 100644 --- a/app/Http/Controllers/TwoFAccountController.php +++ b/app/Http/Controllers/TwoFAccountController.php @@ -142,8 +142,7 @@ public function update(Request $request, $id) throw $e; } - - if( $twofaccount->type === 'hotp' ) { + if( $twofaccount->otpType === 'hotp' ) { // HOTP can be desynchronized from the verification // server so we let the user the possibility to force diff --git a/app/TwoFAccount.php b/app/TwoFAccount.php index ffcda83e..b364fe65 100644 --- a/app/TwoFAccount.php +++ b/app/TwoFAccount.php @@ -39,7 +39,7 @@ class TwoFAccount extends Model implements Sortable * * @var array */ - protected $appends = ['type', 'counter']; + protected $appends = ['otpType', 'counter']; /** @@ -130,14 +130,25 @@ public function setIconAttribute($value) /** - * Get the account type. + * Get the account OTP type. * * @return string */ - public function getTypeAttribute() + public function getOtpTypeAttribute() { - - return substr( $this->uri, 0, 15 ) === "otpauth://totp/" ? 'totp' : 'hotp'; + switch (substr( $this->uri, 0, 15 )) { + + case "otpauth://totp/" : + return 'totp'; + break; + + case "otpauth://hotp/" : + return 'hotp'; + break; + + default: + return null; + } } /** @@ -148,7 +159,7 @@ public function getTypeAttribute() public function getCounterAttribute() { - if( $this->type === 'hotp' ) { + if( $this->otpType === 'hotp' ) { $otp = Factory::loadFromProvisioningUri($this->uri); return $otp->getCounter(); diff --git a/resources/js/components/TwofaccountShow.vue b/resources/js/components/TwofaccountShow.vue index 7a5d35ed..5a2ab338 100644 --- a/resources/js/components/TwofaccountShow.vue +++ b/resources/js/components/TwofaccountShow.vue @@ -6,10 +6,10 @@

{{ internal_service }}

{{ internal_account }}

{{ displayedOtp }}

-