Operation   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 17
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A verifyJwt() 0 15 2
1
<?php
2
/**
3
 * Teampass - a collaborative passwords manager.
4
 * ---
5
 * This library is distributed in the hope that it will be useful,
6
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8
 * ---
9
 *
10
 * @project   Teampass
11
 * @version    API
12
 *
13
 * @file      Operation.php
14
 * ---
15
 *
16
 * @author    Nils Laumaillé ([email protected])
17
 *
18
 * @copyright 2009-2025 Teampass.net
19
 *
20
 * @license   https://spdx.org/licenses/GPL-3.0-only.html#licenseText GPL-3.0
21
 * ---
22
 *
23
 * @see       https://www.teampass.net
24
 */
25
26
use Firebase\JWT\JWT;
27
use Firebase\JWT\Key;
28
29
class Operation
30
{
31
    public function verifyJwt($jwt)
32
    {
33
        $JWT = new JWT();
34
35
        try {
36
            $JWT->decode($jwt, new Key(DB_PASSWD, 'HS256'));
37
    
38
            // Access is granted.    
39
            return array(
40
                "message" => "Access granted:",
41
                "error" => '',
42
            );
43
    
44
        }catch (Exception $e) {    
45
            return false;
46
        }
47
    }
48
}