From e5c21d1189e186098f2f04494b2e7423c4bb5813 Mon Sep 17 00:00:00 2001 From: Bubka <858858+Bubka@users.noreply.github.com> Date: Mon, 10 Oct 2022 13:43:09 +0200 Subject: [PATCH] Force lowercase for the Algorithm attribute to fix markAsDuplicate() --- app/Models/TwoFAccount.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Models/TwoFAccount.php b/app/Models/TwoFAccount.php index 96de0c05..64da9a17 100644 --- a/app/Models/TwoFAccount.php +++ b/app/Models/TwoFAccount.php @@ -264,7 +264,7 @@ class TwoFAccount extends Model implements Sortable */ public function setAlgorithmAttribute($value) { - $this->attributes['algorithm'] = !$value ? self::SHA1 : $value; + $this->attributes['algorithm'] = !$value ? self::SHA1 : strtolower($value); } @@ -367,7 +367,7 @@ class TwoFAccount extends Model implements Sortable $this->service = Arr::get($parameters, 'service'); $this->icon = Arr::get($parameters, 'icon'); $this->secret = Arr::get($parameters, 'secret'); - $this->algorithm = Arr::get($parameters, 'algorithm', self::SHA1); + $this->algorithm = strtolower(Arr::get($parameters, 'algorithm', self::SHA1)); $this->digits = Arr::get($parameters, 'digits', self::DEFAULT_DIGITS); $this->period = Arr::get($parameters, 'period', $this->otp_type == self::TOTP ? self::DEFAULT_PERIOD : null); $this->counter = Arr::get($parameters, 'counter', $this->otp_type == self::HOTP ? self::DEFAULT_COUNTER : null);