1 <?php
2 /**
3 * @package Joomla.Libraries
4 * @subpackage Authentication
5 *
6 * @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
7 * @license GNU General Public License version 2 or later; see LICENSE.txt
8 */
9
10 defined('JPATH_PLATFORM') or die;
11
12 use Joomla\Registry\Registry;
13
14 /**
15 * Authentication helper class
16 *
17 * @since 3.6.3
18 */
19 abstract class JAuthenticationHelper
20 {
21 /**
22 * Get the Two Factor Authentication Methods available.
23 *
24 * @return array Two factor authentication methods.
25 *
26 * @since 3.6.3
27 */
28 public static function getTwoFactorMethods()
29 {
30 // Get all the Two Factor Authentication plugins.
31 JPluginHelper::importPlugin('twofactorauth');
32
33 // Trigger onUserTwofactorIdentify event and return the two factor enabled plugins.
34 $identities = JEventDispatcher::getInstance()->trigger('onUserTwofactorIdentify', array());
35
36 // Generate array with two factor auth methods.
37 $options = array(
38 JHtml::_('select.option', 'none', JText::_('JGLOBAL_OTPMETHOD_NONE'), 'value', 'text'),
39 );
40
41 if (!empty($identities))
42 {
43 foreach ($identities as $identity)
44 {
45 if (!is_object($identity))
46 {
47 continue;
48 }
49
50 $options[] = JHtml::_('select.option', $identity->method, $identity->title, 'value', 'text');
51 }
52 }
53
54 return $options;
55 }
56 }
57