1
0
mirror of https://github.com/delight-im/PHP-Auth.git synced 2025-07-31 13:20:11 +02:00

Create class 'SecondFactorRequiredException'

This commit is contained in:
Marco
2024-03-11 11:14:12 +01:00
parent 67b4cba4d9
commit db7480be38

View File

@@ -0,0 +1,62 @@
<?php
/*
* PHP-Auth (https://github.com/delight-im/PHP-Auth)
* Copyright (c) delight.im (https://www.delight.im/)
* Licensed under the MIT License (https://opensource.org/licenses/MIT)
*/
namespace Delight\Auth;
/** Exception that is thrown when a first factor has been successfully provided for authentification but a second one is still required */
class SecondFactorRequiredException extends AuthException {
protected $totp;
protected $smsRecipient;
protected $smsOtpValue;
protected $emailRecipient;
protected $emailOtpValue;
public function hasTotpOption() {
return !empty($this->totp);
}
public function hasSmsOption() {
return !empty($this->smsRecipient) && !empty($this->smsOtpValue);
}
public function getSmsRecipient() {
return $this->smsRecipient;
}
public function getSmsOtpValue() {
return $this->smsOtpValue;
}
public function hasEmailOption() {
return !empty($this->emailRecipient) && !empty($this->emailOtpValue);
}
public function getEmailRecipient() {
return $this->emailRecipient;
}
public function getEmailOtpValue() {
return $this->emailOtpValue;
}
public function addTotpOption() {
$this->totp = true;
}
public function addSmsOption($recipient, $otpValue) {
$this->smsRecipient = !empty($recipient) ? (string) $recipient : null;
$this->smsOtpValue = !empty($otpValue) ? (string) $otpValue : null;
}
public function addEmailOption($recipient, $otpValue) {
$this->emailRecipient = !empty($recipient) ? (string) $recipient : null;
$this->emailOtpValue = !empty($otpValue) ? (string) $otpValue : null;
}
}