Warning::process()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 12
rs 10
c 0
b 0
f 0
cc 3
nc 2
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\Module\preprodwarning\Auth\Process;
6
7
use SimpleSAML\Auth;
8
use SimpleSAML\Module;
9
use SimpleSAML\Utils;
10
11
/**
12
 * Give a warning that the user is accessing a test system, not a production system.
13
 *
14
 * @package SimpleSAMLphp
15
 */
16
17
class Warning extends Auth\ProcessingFilter
18
{
19
    /**
20
     * Process a authentication response.
21
     *
22
     * This function saves the state, and redirects the user to the page where the user
23
     * can authorize the release of the attributes.
24
     *
25
     * @param array $state  The state of the response.
26
     */
27
    public function process(array &$state): void
28
    {
29
        if (isset($state['isPassive']) && $state['isPassive'] === true) {
30
            // We have a passive request. Skip the warning
31
            return;
32
        }
33
34
        // Save state and redirect.
35
        $id = Auth\State::saveState($state, 'warning:request');
36
        $url = Module::getModuleURL('preprodwarning/warning');
37
        $httpUtils = new Utils\HTTP();
38
        $httpUtils->redirectTrustedURL($url, ['StateId' => $id]);
39
    }
40
}
41