Fix undefined array key warning in auth.php

Got the following warnings on PHP 8.

- Undefined array key "DW<cookie_hash>" in .../inc/auth.php on line 248
- Trying to access array offset on value of type null in .../inc/auth.php on line 248
This commit is contained in:
Damien Regad 2021-01-26 23:41:26 +01:00
parent a8f9f939d4
commit 0058ae75b0
1 changed files with 14 additions and 12 deletions

View File

@ -245,19 +245,21 @@ function auth_login($user, $pass, $sticky = false, $silent = false) {
// we got a cookie - see if we can trust it
// get session info
$session = $_SESSION[DOKU_COOKIE]['auth'];
if(isset($session) &&
$auth->useSessionCache($user) &&
($session['time'] >= time() - $conf['auth_security_timeout']) &&
($session['user'] == $user) &&
($session['pass'] == sha1($pass)) && //still crypted
($session['buid'] == auth_browseruid())
) {
if (isset($_SESSION[DOKU_COOKIE])) {
$session = $_SESSION[DOKU_COOKIE]['auth'];
if (isset($session) &&
$auth->useSessionCache($user) &&
($session['time'] >= time() - $conf['auth_security_timeout']) &&
($session['user'] == $user) &&
($session['pass'] == sha1($pass)) && //still crypted
($session['buid'] == auth_browseruid())
) {
// he has session, cookie and browser right - let him in
$INPUT->server->set('REMOTE_USER', $user);
$USERINFO = $session['info']; //FIXME move all references to session
return true;
// he has session, cookie and browser right - let him in
$INPUT->server->set('REMOTE_USER', $user);
$USERINFO = $session['info']; //FIXME move all references to session
return true;
}
}
// no we don't trust it yet - recheck pass but silent
$secret = auth_cookiesalt(!$sticky, true); //bind non-sticky to session