New function "isAuthenticated"
This commit is contained in:
parent
89f02a1125
commit
83b00ef308
26 changed files with 64 additions and 48 deletions
|
@ -27,7 +27,7 @@ use Friendica\Util\Temporal;
|
|||
|
||||
function cal_init(App $a)
|
||||
{
|
||||
if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
|
||||
if (Config::get('system', 'block_public') && !Session::isAuthenticated()) {
|
||||
throw new \Friendica\Network\HTTPException\ForbiddenException(L10n::t('Access denied.'));
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ function community_content(App $a, $update = 0)
|
|||
{
|
||||
$o = '';
|
||||
|
||||
if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
|
||||
if (Config::get('system', 'block_public') && !Session::isAuthenticated()) {
|
||||
notice(L10n::t('Public access denied.') . EOL);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ use Friendica\Core\Config;
|
|||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Module\Login;
|
||||
use Friendica\Protocol\DFRN;
|
||||
|
@ -49,7 +50,7 @@ function dfrn_poll_init(App $a)
|
|||
$hidewall = false;
|
||||
|
||||
if (($dfrn_id === '') && empty($_POST['dfrn_id'])) {
|
||||
if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
|
||||
if (Config::get('system', 'block_public') && !Session::isAuthenticated()) {
|
||||
throw new \Friendica\Network\HTTPException\ForbiddenException();
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ use Friendica\Core\Logger;
|
|||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Group;
|
||||
|
@ -592,7 +593,7 @@ function dfrn_request_content(App $a)
|
|||
exit();
|
||||
} else {
|
||||
// Normal web request. Display our user's introduction form.
|
||||
if ((Config::get('system', 'block_public')) && (!local_user()) && (!remote_user())) {
|
||||
if (Config::get('system', 'block_public') && !Session::isAuthenticated()) {
|
||||
if (!Config::get('system', 'local_block')) {
|
||||
notice(L10n::t('Public access denied.') . EOL);
|
||||
return;
|
||||
|
|
|
@ -32,7 +32,7 @@ function display_init(App $a)
|
|||
Objects::rawContent();
|
||||
}
|
||||
|
||||
if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
|
||||
if (Config::get('system', 'block_public') && !Session::isAuthenticated()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -196,7 +196,7 @@ function display_fetchauthor($a, $item)
|
|||
|
||||
function display_content(App $a, $update = false, $update_uid = 0)
|
||||
{
|
||||
if (Config::get('system','block_public') && !local_user() && !remote_user()) {
|
||||
if (Config::get('system','block_public') && !Session::isAuthenticated()) {
|
||||
throw new HTTPException\ForbiddenException(L10n::t('Public access denied.'));
|
||||
}
|
||||
|
||||
|
|
|
@ -6,13 +6,14 @@ use Friendica\App;
|
|||
use Friendica\Core\Config;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Profile;
|
||||
use Friendica\Model\User;
|
||||
|
||||
function hcard_init(App $a)
|
||||
{
|
||||
$blocked = Config::get('system', 'block_public') && !local_user() && !remote_user();
|
||||
$blocked = Config::get('system', 'block_public') && !Session::isAuthenticated();
|
||||
|
||||
if ($a->argc > 1) {
|
||||
$which = $a->argv[1];
|
||||
|
|
|
@ -25,6 +25,7 @@ use Friendica\Core\L10n;
|
|||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Attach;
|
||||
|
@ -45,7 +46,7 @@ use Friendica\Worker\Delivery;
|
|||
require_once 'include/items.php';
|
||||
|
||||
function item_post(App $a) {
|
||||
if (!local_user() && !remote_user()) {
|
||||
if (!Session::isAuthenticated()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -860,7 +861,7 @@ function item_post_return($baseurl, $api_source, $return_path)
|
|||
|
||||
function item_content(App $a)
|
||||
{
|
||||
if (!local_user() && !remote_user()) {
|
||||
if (!Session::isAuthenticated()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ use Friendica\Util\XML;
|
|||
|
||||
function photos_init(App $a) {
|
||||
|
||||
if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
|
||||
if (Config::get('system', 'block_public') && !Session::isAuthenticated()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ function photos_init(App $a) {
|
|||
|
||||
$albums = Photo::getAlbums($a->data['user']['uid']);
|
||||
|
||||
$albums_visible = ((intval($a->data['user']['hidewall']) && !local_user() && !remote_user()) ? false : true);
|
||||
$albums_visible = ((intval($a->data['user']['hidewall']) && !Session::isAuthenticated()) ? false : true);
|
||||
|
||||
// add various encodings to the array so we can just loop through and pick them out in a template
|
||||
$ret = ['success' => false];
|
||||
|
@ -829,7 +829,7 @@ function photos_content(App $a)
|
|||
// photos/name/image/xxxxx/edit
|
||||
// photos/name/image/xxxxx/drop
|
||||
|
||||
if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
|
||||
if (Config::get('system', 'block_public') && !Session::isAuthenticated()) {
|
||||
notice(L10n::t('Public access denied.') . EOL);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ function redir_init(App $a) {
|
|||
|
||||
$contact_url = $contact['url'];
|
||||
|
||||
if ((!local_user() && !remote_user()) // Visitors (not logged in or not remotes) can't authenticate.
|
||||
if (!Session::isAuthenticated() // Visitors (not logged in or not remotes) can't authenticate.
|
||||
|| (!empty($a->contact['id']) && $a->contact['id'] == $cid)) // Local user is already authenticated.
|
||||
{
|
||||
$a->redirect(defaults($url, $contact_url));
|
||||
|
@ -74,17 +74,8 @@ function redir_init(App $a) {
|
|||
}
|
||||
}
|
||||
|
||||
// When the remote page does support OWA, then we enforce the use of it
|
||||
$basepath = Contact::getBasepath($contact_url);
|
||||
if (Strings::compareLink($basepath, System::baseUrl())) {
|
||||
$use_magic = true;
|
||||
} else {
|
||||
$serverret = Network::curl($basepath . '/magic');
|
||||
$use_magic = $serverret->isSuccess();
|
||||
}
|
||||
|
||||
// Doing remote auth with dfrn.
|
||||
if (local_user() && !$use_magic && (!empty($contact['dfrn-id']) || !empty($contact['issued-id'])) && empty($contact['pending'])) {
|
||||
if (local_user() && (!empty($contact['dfrn-id']) || !empty($contact['issued-id'])) && empty($contact['pending'])) {
|
||||
$dfrn_id = $orig_id = (($contact['issued-id']) ? $contact['issued-id'] : $contact['dfrn-id']);
|
||||
|
||||
if ($contact['duplex'] && $contact['issued-id']) {
|
||||
|
|
|
@ -11,6 +11,7 @@ use Friendica\Core\Cache;
|
|||
use Friendica\Core\Config;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Item;
|
||||
|
@ -83,18 +84,18 @@ function search_init(App $a) {
|
|||
}
|
||||
|
||||
function search_content(App $a) {
|
||||
if (Config::get('system','block_public') && !local_user() && !remote_user()) {
|
||||
if (Config::get('system','block_public') && !Session::isAuthenticated()) {
|
||||
notice(L10n::t('Public access denied.') . EOL);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config::get('system','local_search') && !local_user() && !remote_user()) {
|
||||
if (Config::get('system','local_search') && !Session::isAuthenticated()) {
|
||||
$e = new \Friendica\Network\HTTPException\ForbiddenException(L10n::t("Only logged in users are permitted to perform a search."));
|
||||
$e->httpdesc = L10n::t("Public access denied.");
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if (Config::get('system','permit_crawling') && !local_user() && !remote_user()) {
|
||||
if (Config::get('system','permit_crawling') && !Session::isAuthenticated()) {
|
||||
// Default values:
|
||||
// 10 requests are "free", after the 11th only a call per minute is allowed
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ use Friendica\Util\XML;
|
|||
|
||||
function subthread_content(App $a) {
|
||||
|
||||
if (!local_user() && !remote_user()) {
|
||||
if (!Session::isAuthenticated()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ use Friendica\Core\Hook;
|
|||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Item;
|
||||
|
@ -16,7 +17,7 @@ use Friendica\Worker\Delivery;
|
|||
|
||||
function tagger_content(App $a) {
|
||||
|
||||
if (!local_user() && !remote_user()) {
|
||||
if (!Session::isAuthenticated()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ use Friendica\Util\Security;
|
|||
|
||||
function videos_init(App $a)
|
||||
{
|
||||
if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
|
||||
if (Config::get('system', 'block_public') && !Session::isAuthenticated()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ function videos_content(App $a)
|
|||
// videos/name/video/xxxxx/edit
|
||||
|
||||
|
||||
if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
|
||||
if (Config::get('system', 'block_public') && !Session::isAuthenticated()) {
|
||||
notice(L10n::t('Public access denied.') . EOL);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue