Force lowercase for the Algorithm attribute to fix markAsDuplicate()

This commit is contained in:
Bubka 2022-10-10 13:43:09 +02:00
parent 7c924126a3
commit e5c21d1189

View File

@ -264,7 +264,7 @@ class TwoFAccount extends Model implements Sortable
*/ */
public function setAlgorithmAttribute($value) 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->service = Arr::get($parameters, 'service');
$this->icon = Arr::get($parameters, 'icon'); $this->icon = Arr::get($parameters, 'icon');
$this->secret = Arr::get($parameters, 'secret'); $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->digits = Arr::get($parameters, 'digits', self::DEFAULT_DIGITS);
$this->period = Arr::get($parameters, 'period', $this->otp_type == self::TOTP ? self::DEFAULT_PERIOD : null); $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); $this->counter = Arr::get($parameters, 'counter', $this->otp_type == self::HOTP ? self::DEFAULT_COUNTER : null);