New function "isAuthenticated"

This commit is contained in:
Michael 2019-09-28 18:09:11 +00:00
parent 89f02a1125
commit 83b00ef308
26 changed files with 64 additions and 48 deletions

View file

@ -11,6 +11,7 @@ use Friendica\Content\Feature;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
use Friendica\Core\Session;
use Friendica\Util\Network;
/**
@ -333,7 +334,7 @@ class ACL extends BaseObject
*/
public static function contactAutocomplete($search, $mode, int $page = 1)
{
if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
if (Config::get('system', 'block_public') && !Session::isAuthenticated()) {
return [];
}

View file

@ -53,7 +53,7 @@ class Session
/**
* Retrieves a key from the session super global or the defaults if the key is missing or the value is falsy.
*
*
* Handle the case where session_start() hasn't been called and the super global isn't available.
*
* @param string $name
@ -255,4 +255,18 @@ class Session
}
DBA::close($remote_contacts);
}
/**
* Returns if the current visitor is authenticated
*
* @return boolean "true" when visitor is either a local or remote user
*/
public static function isAuthenticated()
{
if (empty($_SESSION['authenticated'])) {
return false;
}
return $_SESSION['authenticated'];
}
}