protected function getInput() { $name = $this->name; $value = $this->value; if (!isset($value['code']) || empty($value['code'])) { $value['code'] = GoogleAuthenticationHelper::backupCode(); } if (!isset($value['count']) || empty($value['count'])) { $value['count'] = 0; } ob_start(); ?> <fieldset class=""> <label class=""><?php echo JText::_('PLG_TFA_CODE_BACKUP'); ?> </label> <input type="text" size="6" name="<?php echo $name; ?> [code]" value="<?php echo $value['code']; ?> " readonly="true" title="<?php echo JText::_('PLG_TFA_CODE_BACKUP_DESC'); ?> " /> <label class=""><?php echo JText::_('PLG_TFA_CODE_USED'); ?> </label> <fieldset id="jform_params_is_enable" class="radio"> <input type="radio" name="<?php echo $name; ?> [count]" value="1" <?php echo $value['count'] == 1 ? 'checked=checked' : ''; ?> title="<?php echo JText::_('PLG_TFA_CODE_ONE_TIME_DESC'); ?> "/> <label class=""><?php echo JText::_('PLG_TFA_CODE_ONE_TIME'); ?> </label> <input type="radio" name="<?php echo $name; ?> [count]" value="0" <?php echo $value['count'] == 0 ? 'checked=checked' : ''; ?> title="<?php echo JText::_('PLG_TFA_CODE_UNLIMITED_DESC'); ?> "/> <label class=""><?php echo JText::_('PLG_TFA_CODE_UNLIMITED'); ?> </label> </fieldset> </fieldset> <?php $html = ob_get_contents(); ob_end_clean(); return $html; }
/** * * if backup code use for one time then change backup-code after used */ private function _changeCodeFrequency() { $user = JFactory::getUser(); $tfa = $user->get('_params')->get('tfa'); // if unlimited used if (!$tfa->backup->count) { return true; } $tfa->backup->code = GoogleAuthenticationHelper::backupCode(); // set new code $user->setParam('tfa', $tfa); // save user with new backup code $user->save(); }