Add otp_type property when returning an OTP object

This commit is contained in:
Bubka 2021-10-05 23:53:50 +02:00
parent c27bef1819
commit f19fb0adad
2 changed files with 5 additions and 0 deletions

View File

@ -7,6 +7,9 @@ class OtpDto
/* @var integer */ /* @var integer */
public string $password; public string $password;
/* @var integer */
public string $otp_type;
/* @var integer */ /* @var integer */
public ?int $generated_at; public ?int $generated_at;

View File

@ -132,12 +132,14 @@ class TwoFAccountService
if ( $this->tokenOtpType() === 'totp' ) { if ( $this->tokenOtpType() === 'totp' ) {
$OtpDto->generated_at = time(); $OtpDto->generated_at = time();
$OtpDto->otp_type = 'totp';
$OtpDto->password = $this->token->at($OtpDto->generated_at); $OtpDto->password = $this->token->at($OtpDto->generated_at);
$OtpDto->valid_for = $this->token->getParameter('period'); $OtpDto->valid_for = $this->token->getParameter('period');
} }
else if ( $this->tokenOtpType() === 'hotp' ) { else if ( $this->tokenOtpType() === 'hotp' ) {
$counter = $this->token->getCounter(); $counter = $this->token->getCounter();
$OtpDto->otp_type = 'hotp';
$OtpDto->password = $this->token->at($counter); $OtpDto->password = $this->token->at($counter);
$OtpDto->counter = $counter + 1; $OtpDto->counter = $counter + 1;
} }