Skip to content
Snippets Groups Projects
Commit 8500e50b authored by abdulaziz zaid's avatar abdulaziz zaid
Browse files

Issue #3485953 by sarwan_verma, will_frank, riddhi.addweb, abdulaziz zaid: Drupal 11 Compatibility

parent 7939429b
Branches
Tags
No related merge requests found
name: Email TFA
description: Provide An Email TFA for users after login.
core_version_requirement: ^9 || ^10
core_version_requirement: ^9 || ^10 || ^11
package: Security
type: module
configure: email_tfa.settings
......@@ -3,11 +3,14 @@
namespace Drupal\email_tfa\Form;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Config\TypedConfigManagerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Site\Settings;
use Drupal\user\RoleInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\user\Entity\Role;
/**
* Class TfaConfigForm settings.
......@@ -23,8 +26,8 @@ class EmailTfaConfigForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public function __construct(ConfigFactoryInterface $config_factory, ModuleHandlerInterface $module_handler) {
parent::__construct($config_factory);
public function __construct(ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typedConfigManager, ModuleHandlerInterface $module_handler) {
parent::__construct($config_factory, $typedConfigManager);
$this->moduleHandler = $module_handler;
}
......@@ -34,6 +37,7 @@ class EmailTfaConfigForm extends ConfigFormBase {
public static function create(ContainerInterface $container) {
return new static(
$container->get('config.factory'),
$container->get('config.typed'),
$container->get('module_handler')
);
}
......@@ -141,7 +145,12 @@ class EmailTfaConfigForm extends ConfigFormBase {
];
// Load all roles.
$roles = user_role_names(TRUE);
$roles = Role::loadMultiple();
$roles = array_map(function ($role) {
return $role->label();
}, $roles);
// remove anonymous role.
unset($roles[RoleInterface::ANONYMOUS_ID]);
$form['email_tfa_settings']['settings']['ignore_role'] = [
'#type' => 'checkboxes',
'#title' => $this->t('Roles'),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment