* Retrieves the user's role from the users file. * * @param string $username * @return string|null The role string (e.g. "1" for admin) or null if not found. */
(string $username)
| 43 | * @return string|null The role string (e.g. "1" for admin) or null if not found. |
| 44 | */ |
| 45 | public static function getUserRole(string $username): ?string |
| 46 | { |
| 47 | $usersFile = USERS_DIR . USERS_FILE; |
| 48 | if (file_exists($usersFile)) { |
| 49 | foreach (file($usersFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) as $line) { |
| 50 | $parts = explode(":", trim($line)); |
| 51 | if (count($parts) >= 3 && $parts[0] === $username) { |
| 52 | return trim($parts[2]); |
| 53 | } |
| 54 | } |
| 55 | } |
| 56 | return null; |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Ensure a local FileRise account exists for an OIDC user, and keep |
no outgoing calls
no test coverage detected