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 */
public string $password;
/* @var integer */
public string $otp_type;
/* @var integer */
public ?int $generated_at;

View File

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