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

Method getUserRole

src/FileRise/Domain/AuthModel.php:45–57  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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

Callers 15

webdav.phpFile · 0.45
isAdminMethod · 0.45
finalizeLoginMethod · 0.45
finishBrowserLoginMethod · 0.45
checkAuthMethod · 0.45
requireAdminMethod · 0.45
requireAdminMethod · 0.45
verifyTOTPMethod · 0.45
isAdminMethod · 0.45
userExistsMethod · 0.45
fromAuthPayloadMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected