Back to AuthenticationHelper class

Method getTwoFactorMethods

public static array
getTwoFactorMethods
()
Get the Two Factor Authentication Methods available.
Returns
  • array Two factor authentication methods.
Since
  • 3.6.3

Method getTwoFactorMethods - Source code

/**
 * Get the Two Factor Authentication Methods available.
 *
 * @return  array  Two factor authentication methods.
 *
 * @since   3.6.3
 */
public static function getTwoFactorMethods()
{
    // Get all the Two Factor Authentication plugins.
    PluginHelper::importPlugin('twofactorauth');
    // Trigger onUserTwofactorIdentify event and return the two factor enabled plugins.
    $identities = Factory::getApplication()->triggerEvent('onUserTwofactorIdentify', array());
    // Generate array with two factor auth methods.
    $options = array(HTMLHelper::_('select.option', 'none', Text::_('JGLOBAL_OTPMETHOD_NONE'), 'value', 'text'));
    if (!empty($identities)) {
        foreach ($identities as $identity) {
            if (!\is_object($identity)) {
                continue;
            }
            $options[] = HTMLHelper::_('select.option', $identity->method, $identity->title, 'value', 'text');
        }
    }
    return $options;
}