From 27e21231e168e5a2a89563b2538a4f86df24e582 Mon Sep 17 00:00:00 2001 From: Willi Eggeling Date: Thu, 31 Aug 2017 00:39:15 +0200 Subject: added option to redirect all anonymous users to login page - new setting *force_login* added and documented - if both, *force_login* and *hide_public_links* are set to true, all requests (except for the feeds) are redirected to the login page --- index.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'index.php') diff --git a/index.php b/index.php index 218d317d..fb00a9fa 100644 --- a/index.php +++ b/index.php @@ -718,6 +718,23 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history) $query = (isset($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : ''; $targetPage = Router::findPage($query, $_GET, isLoggedIn()); + if ( + // if the user isn't logged in + !isLoggedIn() && + // and Shaarli doesn't have public content... + $conf->get('privacy.hide_public_links') && + // and is configured to enforce the login + $conf->get('privacy.force_login') && + // and the current page isn't already the login page + $targetPage !== Router::$PAGE_LOGIN && + // and the user is not requesting a feed (which would lead to a different content-type as expected) + $targetPage !== Router::$PAGE_FEED_ATOM && + $targetPage !== Router::$PAGE_FEED_RSS + ) { + // force current page to be the login page + $targetPage = Router::$PAGE_LOGIN; + } + // Call plugin hooks for header, footer and includes, specifying which page will be rendered. // Then assign generated data to RainTPL. $common_hooks = array( -- cgit v1.2.3