MCPcopy Create free account
hub / github.com/error311/FileRise / getTOTPSecret

Method getTOTPSecret

src/FileRise/Domain/UserModel.php:956–971  ·  view source on GitHub ↗

* Get decrypted TOTP secret. */

($username)

Source from the content-addressed store, hash-verified

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.

Callers 1

verifyTOTPMethod · 0.80

Calls 1

decryptDataFunction · 0.85

Tested by

no test coverage detected