* Get decrypted TOTP secret. */
($username)
| 954 | * Get decrypted TOTP secret. |
| 955 | */ |
| 956 | public static function getTOTPSecret($username) |
| 957 | { |
| 958 | global $encryptionKey; |
| 959 | $usersFile = USERS_DIR . USERS_FILE; |
| 960 | if (!file_exists($usersFile)) { |
| 961 | return null; |
| 962 | } |
| 963 | $lines = file($usersFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) ?: []; |
| 964 | foreach ($lines as $line) { |
| 965 | $parts = explode(':', trim($line)); |
| 966 | if (count($parts) >= 4 && strcasecmp($parts[0], $username) === 0 && !empty($parts[3])) { |
| 967 | return decryptData($parts[3], $encryptionKey); |
| 968 | } |
| 969 | } |
| 970 | return null; |
| 971 | } |
| 972 | |
| 973 | /** |
| 974 | * Get role ('1' admin, '0' user) or null. |
no test coverage detected