Log user in automatically if a request with HTTP auth is received

This commit is contained in:
Alex Cabal 2022-07-12 11:30:03 -05:00
parent 216e63f014
commit c457af896c
6 changed files with 25 additions and 10 deletions

View file

@ -28,3 +28,15 @@ if(SITE_STATUS == SITE_STATUS_LIVE){
}
$GLOBALS['User'] = Session::GetLoggedInUser();
if($GLOBALS['User'] === null){
$httpBasicAuthLogin = $_SERVER['PHP_AUTH_USER'] ?? null;
if($httpBasicAuthLogin !== null){
// If there's no logged in user, but a username was sent via HTTP basic auth,
// log them in while we're here.
$session = new Session();
$session->Create($httpBasicAuthLogin);
}
}