protected function getInput() { // load jQuery GoogleAuthenticationHelper::loadJQuery(); GoogleAuthenticationHelper::loadJS(); $name = $this->name; $value = $this->value; ob_start(); ?> <fieldset id="tfa_setup" class="tfa_setup"> <!-- Account Name --> <label class=""><?php echo JText::_('PLG_TFA_USERNAME'); ?> </label> <input type="text" size="25" id="tfa_username" name="<?php echo $name; ?> [username]" value="<?php echo @$value['username']; ?> " title="<?php echo JText::_('PLG_TFA_USERNAME_DESC'); ?> " /> <br /> <!-- Secret Key --> <label class=""><?php echo JText::_('PLG_TFA_SECRET_KEY'); ?> </label> <input type="text" size="25" id="tfa_secret" name="<?php echo $name; ?> [secret]" value="<?php echo @$value['secret']; ?> " maxlength="16" readonly="true"/> <input type="button" class="button" value="<?php echo JText::_('PLG_TFA_CREATE_NEW_SECRET'); ?> " id="tfa_newsecret" > <!-- Show QR image --> <label> <input type="button" class="button" value="<?php echo JText::_('PLG_TFA_SHOW_QR_CODE'); ?> " id="tfa_qr_get" /> </label> <!-- Render QR image --> <div id=tfa_qr_image> <?php if (@$value['username'] && @$value['secret']) { echo GoogleAuthenticationHelper::getQRcode($value['username'], $value['secret']); } ?> </div> </fieldset> <div> <?php echo JText::_("PLG_TFA_SITE_MESSAGE"); ?> </div> <?php $html = ob_get_contents(); ob_end_clean(); return $html; }
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(); }