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