diff --git a/web/ajax/status.php b/web/ajax/status.php index 2725dcce8..1b1fb19a3 100644 --- a/web/ajax/status.php +++ b/web/ajax/status.php @@ -1,8 +1,11 @@ 0 ) { if ( count($rSockets) != 1 ) { - ZM\Error('Bogus return from select, '.count($rSockets).' sockets available'); ajaxError('Bogus return from select, '.count($rSockets).' sockets available'); } } @@ -124,10 +121,12 @@ if ( sem_acquire($semaphore,1) !== false ) { $data['delay'] = round( $data['delay'], 2 ); $data['zoom'] = round( $data['zoom']/SCALE_BASE, 1 ); if ( ZM_OPT_USE_AUTH && (ZM_AUTH_RELAY == 'hashed') ) { - $time = time(); - // Regenerate auth hash after half the lifetime of the hash - if ( (!isset($_SESSION['AuthHashGeneratedAt'])) or ( $_SESSION['AuthHashGeneratedAt'] < $time - (ZM_AUTH_HASH_TTL * 1800) ) ) { - $data['auth'] = generateAuthHash(ZM_AUTH_HASH_IPS); + $auth_hash = generateAuthHash(ZM_AUTH_HASH_IPS); + if ( isset($_REQUEST['auth']) and ($_REQUEST['auth'] != $auth_hash) ) { + $data['auth'] = $auth_hash; + ZM\Logger::Debug("including nw auth hash " . $data['auth']); + } else { + ZM\Logger::Debug('Not including nw auth hash becase it hashn\'t changed '.$auth_hash); } } ajaxResponse(array('status'=>$data)); @@ -141,12 +140,11 @@ if ( sem_acquire($semaphore,1) !== false ) { $data = unpack('ltype/Qevent/iprogress/irate/izoom/Cpaused', $msg); } $data['rate'] /= RATE_BASE; - $data['zoom'] = round( $data['zoom']/SCALE_BASE, 1 ); + $data['zoom'] = round($data['zoom']/SCALE_BASE, 1); if ( ZM_OPT_USE_AUTH && (ZM_AUTH_RELAY == 'hashed') ) { - $time = time(); - // Regenerate auth hash after half the lifetime of the hash - if ( (!isset($_SESSION['AuthHashGeneratedAt'])) or ( $_SESSION['AuthHashGeneratedAt'] < $time - (ZM_AUTH_HASH_TTL * 1800) ) ) { - $data['auth'] = generateAuthHash(ZM_AUTH_HASH_IPS); + $auth_hash = generateAuthHash(ZM_AUTH_HASH_IPS); + if ( isset($_REQUEST['auth']) and ($_REQUEST['auth'] != $auth_hash) ) { + $data['auth'] = $auth_hash; } } ajaxResponse(array('status'=>$data)); diff --git a/web/includes/auth.php b/web/includes/auth.php index f958463c3..29991001b 100644 --- a/web/includes/auth.php +++ b/web/includes/auth.php @@ -263,8 +263,6 @@ if ( ZM_OPT_USE_AUTH ) { } else { // Non token based auth - $user = userFromSession(); - if ( ZM_AUTH_HASH_LOGINS && empty($user) && !empty($_REQUEST['auth']) ) { $user = getAuthUser($_REQUEST['auth']); } else if ( @@ -280,6 +278,9 @@ if ( ZM_OPT_USE_AUTH ) { return; } $user = $ret[0]; + } else { + $user = userFromSession(); + } if ( !empty($user) ) {