Skip to content
Snippets Groups Projects
Commit a21aebc8 authored by Mingsong Hu's avatar Mingsong Hu
Browse files

Issue #2930355: Add tfa_update_8013() and fix coding standard issue.

parent eb96196c
No related branches found
No related merge requests found
......@@ -307,3 +307,29 @@ function tfa_update_8012() {
->clear('cookie_name')
->save();
}
/**
* Grant eligible users with "reset pass skip tfa" permission.
*
* Set default value as true for 'reset_pass_skip_enabled'.
*/
function tfa_update_8013() {
if ($roles = Role::loadMultiple()) {
foreach ($roles as $role) {
if ($role->hasPermission('administer tfa for other users') && $role->hasPermission('admin tfa settings')) {
// The user role has 'admin tfa settings'
// and 'administer tfa for other users' permission already.
// Grant the new permssion to this user role.
$role->grantPermission('reset pass skip tfa');
$role->save();
}
}
}
$config = \Drupal::configFactory()->getEditable('tfa.settings');
// Allow administrator role to skip TFA
// by defualt, when resetting password.
$config
->set('reset_pass_skip_enabled', TRUE)
->save();
}
......@@ -17,4 +17,4 @@ services:
tfa.route_subscriber:
class: Drupal\tfa\Routing\TfaRouteSubscriber
tags:
- { name: event_subscriber }
\ No newline at end of file
- { name: event_subscriber }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment