forked from CashWilliams/tfa
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathtfa.module
37 lines (33 loc) · 970 Bytes
/
tfa.module
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
<?php
/**
* @file
* Contains tfa.module.
*/
use Drupal\Core\Session\AccountInterface;
use Drupal\block\Entity\Block;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Access\AccessResult;
/**
* Implements hook_help().
*/
function tfa_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
// Main module help for the tfa module.
case 'help.page.tfa':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('Pluggable provider of second factor authentication for Drupal') . '</p>';
return $output;
}
}
/**
* Implements hook_block_access().
*
* Remove access to the core user_login_block so we can replace with the TFA
* login block.
*/
function tfa_block_access(Block $block, $operation, AccountInterface $account) {
if (\Drupal::config('tfa.settings')->get('enabled') && $block->getPluginId() === 'user_login_block') {
return AccessResult::forbidden();
}
}