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

Function loadUserPermissions

config/config.php:330–355  ·  view source on GitHub ↗

Helper to load JSON permissions (with optional decryption)

($username)

Source from the content-addressed store, hash-verified

328
329// Helper to load JSON permissions (with optional decryption)
330function loadUserPermissions($username)
331{
332 global $encryptionKey;
333 $permissionsFile = USERS_DIR . 'userPermissions.json';
334 if (!file_exists($permissionsFile)) {
335 return false;
336 }
337
338 $content = file_get_contents($permissionsFile);
339 $decrypted = decryptData($content, $encryptionKey);
340 $json = ($decrypted !== false) ? $decrypted : $content;
341 $permsAll = json_decode($json, true);
342
343 if (!is_array($permsAll)) {
344 return false;
345 }
346
347 // Try exact match first, then lowercase (since we store keys lowercase elsewhere)
348 $uExact = (string)$username;
349 $uLower = strtolower($uExact);
350
351 $row = $permsAll[$uExact] ?? $permsAll[$uLower] ?? null;
352
353 // Normalize: always return an array when found, else false (to preserve current callers’ behavior)
354 return is_array($row) ? $row : false;
355}
356
357function fr_local_user_exists($username): bool
358{

Callers 15

webdav.phpFile · 0.85
loadPermsForMethod · 0.85
loadPermsMethod · 0.85
finalizeLoginMethod · 0.85
finishBrowserLoginMethod · 0.85
checkAuthMethod · 0.85
handleUploadMethod · 0.85
removeChunksMethod · 0.85
checkExistingMethod · 0.85
verifyTOTPMethod · 0.85
loadPermsMethod · 0.85

Calls 1

decryptDataFunction · 0.85

Tested by

no test coverage detected