public function MobileNumberTfa::__construct in Mobile Number 7
MobileNumberTfa constructor.
Parameters
array $context: Context array.
Throws
Exception
Overrides TfaBasePlugin::__construct
File
- src/
MobileNumberTfa.php, line 27 - Contains MobileNumberTfa.
Class
- MobileNumberTfa
- Class MobileNumberTfa is a validation and sending plugin for TFA.
Code
public function __construct(array $context) {
parent::__construct($context);
if (!empty($context['validate_context']) && !empty($context['validate_context']['code'])) {
$this->code = $context['validate_context']['code'];
}
if (!empty($context['validate_context']) && !empty($context['validate_context']['verification_token'])) {
$this->verificationToken = $context['validate_context']['verification_token'];
}
$this->codeLength = 4;
if ($m = mobile_number_tfa_account_number($context['uid'])) {
try {
$this->mobileNumber = new MobileNumber($m);
} catch (Exception $e) {
throw new Exception("Two factor authentication failed: \n" . $e
->getMessage(), $e
->getCode());
}
}
}