Browse Source

Add getRequestUser() function

master
Skylar Ittner 10 months ago
parent
commit
f1c36fdeb1
1 changed files with 12 additions and 0 deletions
  1. 12
    0
      api/functions.php

+ 12
- 0
api/functions.php View File

@@ -75,6 +75,18 @@ function authenticate(): bool {
return true;
}

/**
* Get the User whose credentials were used to make the request.
*/
function getRequestUser(): User {
global $VARS;
if (!empty($_SERVER['PHP_AUTH_USER'])) {
return User::byUsername($_SERVER['PHP_AUTH_USER']);
} else {
return User::byUsername($VARS['username']);
}
}

function checkVars($vars, $or = false) {
global $VARS;
$ok = [];

Loading…
Cancel
Save