From 46337043d00217051b11c988fc689292c50649ff Mon Sep 17 00:00:00 2001 From: Immanuel Onyeka Date: Tue, 19 Mar 2024 13:06:41 -0400 Subject: [PATCH] Show only appropriate pages to guests in navbar nav_loop is seperated into three different loops for general routes, guests, and authenticated users which will be called 'members'. --- .../21232f297a57a5a743894a0e4a801fc3.yaml | 2 +- .../d41d8cd98f00b204e9800998ecf8427e.yaml | 52 +++++++++++ grav-admin/user/data/flex/indexes/pages.json | 2 +- .../21232f297a57a5a743894a0e4a801fc3.yaml | 2 +- .../d41d8cd98f00b204e9800998ecf8427e.yaml | 92 +++++++++++++++++++ .../user/pages/06.register/registration.md | 2 + .../user/plugins/proxy-login/proxy-login.php | 11 +-- .../quark/templates/macros/macros.html.twig | 35 ++++++- skouter.go | 3 - 9 files changed, 186 insertions(+), 15 deletions(-) create mode 100644 grav-admin/user/data/feed/d41d8cd98f00b204e9800998ecf8427e.yaml create mode 100644 grav-admin/user/data/notifications/d41d8cd98f00b204e9800998ecf8427e.yaml diff --git a/grav-admin/user/data/feed/21232f297a57a5a743894a0e4a801fc3.yaml b/grav-admin/user/data/feed/21232f297a57a5a743894a0e4a801fc3.yaml index 6ab2ad3..5d9fc3e 100644 --- a/grav-admin/user/data/feed/21232f297a57a5a743894a0e4a801fc3.yaml +++ b/grav-admin/user/data/feed/21232f297a57a5a743894a0e4a801fc3.yaml @@ -1,4 +1,4 @@ -last_checked: 1710284930 +last_checked: 1710866946 data: - title: 'macOS 14.0 Sonoma Apache Setup: Upgrading Homebrew' diff --git a/grav-admin/user/data/feed/d41d8cd98f00b204e9800998ecf8427e.yaml b/grav-admin/user/data/feed/d41d8cd98f00b204e9800998ecf8427e.yaml new file mode 100644 index 0000000..dd6fe70 --- /dev/null +++ b/grav-admin/user/data/feed/d41d8cd98f00b204e9800998ecf8427e.yaml @@ -0,0 +1,52 @@ +last_checked: 1710866213 +data: + - + title: 'macOS 14.0 Sonoma Apache Setup: Upgrading Homebrew' + url: 'https://getgrav.org/blog/macos-ventura-apache-upgrade-homebrew' + date: 1697803200 + nicetime: '5 months ago' + - + title: 'macOS 14.0 Sonoma Apache Setup: LetsEncrypt SSL' + url: 'https://getgrav.org/blog/macos-sonoma-apache-ssl' + date: 1697799780 + nicetime: '5 months ago' + - + title: 'macOS 14.0 Sonoma Apache Setup: MySQL, Xdebug & More...' + url: 'https://getgrav.org/blog/macos-sonoma-apache-mysql-vhost-apc' + date: 1697799600 + nicetime: '5 months ago' + - + title: 'macOS 14.0 Sonoma Apache Setup: Multiple PHP Versions' + url: 'https://getgrav.org/blog/macos-sonoma-apache-multiple-php-versions' + date: 1697796000 + nicetime: '5 months ago' + - + title: 'Big changes for Email plugin' + url: 'https://getgrav.org/blog/new-email-plugin' + date: 1665048600 + nicetime: '1 years ago' + - + title: 'Skeleton Build Automation' + url: 'https://getgrav.org/blog/skeletons-build-automation' + date: 1614347940 + nicetime: '3 years ago' + - + title: 'Using Grav''s new built-in Web Server' + url: 'https://getgrav.org/blog/using-builtin-webserver' + date: 1612186320 + nicetime: '3 years ago' + - + title: 'Grav 1.7 CLI Self-Upgrade Bug' + url: 'https://getgrav.org/blog/grav-170-cli-self-upgrade-bug' + date: 1611222900 + nicetime: '3 years ago' + - + title: 'Grav 1.7 Released!' + url: 'https://getgrav.org/blog/grav-1.7-released' + date: 1611050100 + nicetime: '3 years ago' + - + title: 'Grav Premium Focus: NextGen Editor' + url: 'https://getgrav.org/blog/premium-focus-nextgen-editor' + date: 1610713140 + nicetime: '3 years ago' diff --git a/grav-admin/user/data/flex/indexes/pages.json b/grav-admin/user/data/flex/indexes/pages.json index b755711..a2f729b 100644 --- a/grav-admin/user/data/flex/indexes/pages.json +++ b/grav-admin/user/data/flex/indexes/pages.json @@ -1 +1 @@ -{"version":"1.5","timestamp":1705023488,"count":14,"index":{"":{"key":"","storage_key":"","template":null,"storage_timestamp":1705010337,"children":{"01.home":1704396086,"02.about":1704398516,"03.typography":1703638467,"04.pricing":1704400398,"05.blog":1703638467,"06.register":1705010214,"07.login":1704398231},"checksum":"eea3a7871f80727e2de9702b8f540707"},"01.home":{"key":"home","storage_key":"01.home","template":"modular","storage_timestamp":1704396086,"markdown":{"":{"modular":1703631506}},"children":{"01._hero":1703718436,"02._features":1703720151,"03._example":1703716188,"04._comparison-pdf":1703719134,"05._info":1703720014,"06._any_device":1704396086},"checksum":"dbbcfea030db5994b105e013be94b15c"},"01.home\/01._hero":{"key":"home\/_hero","storage_key":"01.home\/01._hero","template":"hero","storage_timestamp":1703718436,"markdown":{"":{"hero":1703718436}},"checksum":"45dc2f4a454b5f0609cbe09cfda09790"},"01.home\/02._features":{"key":"home\/_features","storage_key":"01.home\/02._features","template":"features","storage_timestamp":1703720151,"markdown":{"":{"features":1703720151}},"checksum":"ed7be750188fc4ed50ebcdc060f6fb53"},"01.home\/03._example":{"key":"home\/_example","storage_key":"01.home\/03._example","template":"text","storage_timestamp":1703716188,"markdown":{"":{"text":1703713545}},"checksum":"48b2ea373eba19040584a991b21c083c"},"01.home\/04._comparison-pdf":{"key":"home\/_comparison-pdf","storage_key":"01.home\/04._comparison-pdf","template":"text","storage_timestamp":1703719134,"markdown":{"":{"text":1703719134}},"checksum":"f323d6050403b0102c73c174d74b2f0a"},"01.home\/05._info":{"key":"home\/_info","storage_key":"01.home\/05._info","template":"features","storage_timestamp":1703720014,"markdown":{"":{"features":1703720014}},"checksum":"35c9bee0f74fe81449a491e31bf81bcb"},"01.home\/06._any_device":{"key":"home\/_any_device","storage_key":"01.home\/06._any_device","template":"text","storage_timestamp":1704397975,"markdown":{"":{"text":1704397975}},"checksum":"aabfe01503028954e8557c5bff37048d"},"02.about":{"key":"about","storage_key":"02.about","template":"default","storage_timestamp":1704398516,"markdown":{"":{"default":1704398516}},"checksum":"3d12d8cc95786aef7316b6c379752aa0"},"03.typography":{"key":"typography","storage_key":"03.typography","template":"default","storage_timestamp":1703638467,"markdown":{"":{"default":1696264967}},"checksum":"e18e25aa1028384a58d66d7b5c74b799"},"04.pricing":{"key":"pricing","storage_key":"04.pricing","template":"default","storage_timestamp":1704400398,"markdown":{"":{"default":1704400398}},"checksum":"76ddfc1dafa27268dca3f24db2ffa05a"},"05.blog":{"key":"blog","storage_key":"05.blog","template":"blog","storage_timestamp":1703638467,"markdown":{"":{"blog":1703636303}},"checksum":"88a8e8a7109dc2957e9dc3e1fd81fa85"},"06.register":{"key":"register","storage_key":"06.register","template":"registration","storage_timestamp":1705023488,"markdown":{"":{"registration":1705023488}},"checksum":"55b121c2a83afd5a9b12e85234ca7c9b"},"07.login":{"key":"login","storage_key":"07.login","template":"form","storage_timestamp":1704398231,"markdown":{"":{"form":1704398231}},"checksum":"77a4de225317558af65b6079dcc902fb"}}} \ No newline at end of file +{"version":"1.5","timestamp":1710807003,"count":14,"index":{"":{"key":"","storage_key":"","template":null,"storage_timestamp":1705010337,"children":{"01.home":1704396086,"02.about":1704398516,"03.typography":1703638467,"04.pricing":1704400398,"05.blog":1703638467,"06.register":1705010214,"07.login":1704398231},"checksum":"eea3a7871f80727e2de9702b8f540707"},"01.home":{"key":"home","storage_key":"01.home","template":"modular","storage_timestamp":1704396086,"markdown":{"":{"modular":1703631506}},"children":{"01._hero":1703718436,"02._features":1703720151,"03._example":1703716188,"04._comparison-pdf":1703719134,"05._info":1703720014,"06._any_device":1704396086},"checksum":"dbbcfea030db5994b105e013be94b15c"},"01.home\/01._hero":{"key":"home\/_hero","storage_key":"01.home\/01._hero","template":"hero","storage_timestamp":1703718436,"markdown":{"":{"hero":1703718436}},"checksum":"45dc2f4a454b5f0609cbe09cfda09790"},"01.home\/02._features":{"key":"home\/_features","storage_key":"01.home\/02._features","template":"features","storage_timestamp":1703720151,"markdown":{"":{"features":1703720151}},"checksum":"ed7be750188fc4ed50ebcdc060f6fb53"},"01.home\/03._example":{"key":"home\/_example","storage_key":"01.home\/03._example","template":"text","storage_timestamp":1703716188,"markdown":{"":{"text":1703713545}},"checksum":"48b2ea373eba19040584a991b21c083c"},"01.home\/04._comparison-pdf":{"key":"home\/_comparison-pdf","storage_key":"01.home\/04._comparison-pdf","template":"text","storage_timestamp":1703719134,"markdown":{"":{"text":1703719134}},"checksum":"f323d6050403b0102c73c174d74b2f0a"},"01.home\/05._info":{"key":"home\/_info","storage_key":"01.home\/05._info","template":"features","storage_timestamp":1703720014,"markdown":{"":{"features":1703720014}},"checksum":"35c9bee0f74fe81449a491e31bf81bcb"},"01.home\/06._any_device":{"key":"home\/_any_device","storage_key":"01.home\/06._any_device","template":"text","storage_timestamp":1704397975,"markdown":{"":{"text":1704397975}},"checksum":"aabfe01503028954e8557c5bff37048d"},"02.about":{"key":"about","storage_key":"02.about","template":"default","storage_timestamp":1704398516,"markdown":{"":{"default":1704398516}},"checksum":"3d12d8cc95786aef7316b6c379752aa0"},"03.typography":{"key":"typography","storage_key":"03.typography","template":"default","storage_timestamp":1703638467,"markdown":{"":{"default":1696264967}},"checksum":"e18e25aa1028384a58d66d7b5c74b799"},"04.pricing":{"key":"pricing","storage_key":"04.pricing","template":"default","storage_timestamp":1704400398,"markdown":{"":{"default":1704400398}},"checksum":"76ddfc1dafa27268dca3f24db2ffa05a"},"05.blog":{"key":"blog","storage_key":"05.blog","template":"blog","storage_timestamp":1703638467,"markdown":{"":{"blog":1703636303}},"checksum":"88a8e8a7109dc2957e9dc3e1fd81fa85"},"06.register":{"key":"register","storage_key":"06.register","template":"registration","storage_timestamp":1710807003,"markdown":{"":{"registration":1710807003}},"checksum":"af484cd05f9e8645375ff24f629962b1"},"07.login":{"key":"login","storage_key":"07.login","template":"form","storage_timestamp":1704398231,"markdown":{"":{"form":1704398231}},"checksum":"77a4de225317558af65b6079dcc902fb"}}} \ No newline at end of file diff --git a/grav-admin/user/data/notifications/21232f297a57a5a743894a0e4a801fc3.yaml b/grav-admin/user/data/notifications/21232f297a57a5a743894a0e4a801fc3.yaml index 228edfb..850afdf 100644 --- a/grav-admin/user/data/notifications/21232f297a57a5a743894a0e4a801fc3.yaml +++ b/grav-admin/user/data/notifications/21232f297a57a5a743894a0e4a801fc3.yaml @@ -1,4 +1,4 @@ -last_checked: 1710287442 +last_checked: 1710866946 data: feed: - diff --git a/grav-admin/user/data/notifications/d41d8cd98f00b204e9800998ecf8427e.yaml b/grav-admin/user/data/notifications/d41d8cd98f00b204e9800998ecf8427e.yaml new file mode 100644 index 0000000..5c42dc7 --- /dev/null +++ b/grav-admin/user/data/notifications/d41d8cd98f00b204e9800998ecf8427e.yaml @@ -0,0 +1,92 @@ +last_checked: 1710866212 +data: + feed: + - + id: 31 + date: '2024-02-13 11:40' + message: 'πŸ—œοΈOptimize your Grav site with Image Optimize' + link: 'https://getgrav.org/premium/image-optimize' + type: info + location: + - feed + - + id: 30 + date: '2024-02-13 11:40' + message: 'πŸ—³οΈ Please Cast your vote for Grav in the 2024 CMS Critic Awards' + link: 'https://cmscritic.com/vote?utm_source=cmscritic&utm_medium=featured_banner&utm_campaign=CMS+Critic' + type: note + location: + - feed + - + id: 26 + date: '2024-02-10 00:01' + message: 'πŸš€ Grav Premium Plugins and Themes available. Turbo-charge your Grav site today.' + link: 'https://getgrav.org/premium' + type: info + location: + - feed + - + id: 12 + date: '2024-01-17 15:15' + message: 'β˜•οΈ Support Grav for the price of a a month!' + link: 'https://opencollective.com/grav' + type: note + location: + - feed + - + id: 23 + date: '2024-01-05 15:50' + message: 'πŸ™Š Grav community chat has moved from Slack to Discord' + link: 'https://chat.getgrav.org' + type: info + location: + - feed + - + id: 24 + date: '2024-01-05 11:27' + message: 'πŸ™ Thanks to our amazing community, Grav was voted Best Flat File CMS in the 2019 CMS Critics'' Awards!' + link: 'https://www.cmscritic.com/awards/' + type: info + location: + - feed + - + id: 2 + date: '2024-01-05 02:23' + message: 'πŸŽ– Don''t forget to star Grav on GitHub!' + link: 'https://github.com/getgrav/grav' + type: info + location: + - feed + dashboard: + - + id: 27 + date: '2020-02-21 00:01' + message: "\n\nLoading...\n\n\n
\n
\n \n
\n
\n Turbo-charge your Grav site - from the creators of Grav\n Image Optimize - Optimize all the images on your Grav site\n Downloads Pro - Powerful download manager directly integrated with Grav\n Algolia Pro - Class-leading AI-powered search made easy for Grav\n SEO-Magic - Advanced SEO tool for Grav with automatic webshot generator\n Typhoon - The most powerful Grav theme ever built, based on Tailwind 3\n Cloudflare Manager - Configure and manage your domain right within the admin\n Lightbox Gallery - A light, versatile and mobile friendly Lightbox Gallery\n
\n Learn more\n
\n" + type: notice + link: 'https://getgrav.org/premium' + location: + - dashboard + - plugins + - themes + plugins: + - + id: 27 + date: '2020-02-21 00:01' + message: "\n\nLoading...\n\n\n
\n
\n \n
\n
\n Turbo-charge your Grav site - from the creators of Grav\n Image Optimize - Optimize all the images on your Grav site\n Downloads Pro - Powerful download manager directly integrated with Grav\n Algolia Pro - Class-leading AI-powered search made easy for Grav\n SEO-Magic - Advanced SEO tool for Grav with automatic webshot generator\n Typhoon - The most powerful Grav theme ever built, based on Tailwind 3\n Cloudflare Manager - Configure and manage your domain right within the admin\n Lightbox Gallery - A light, versatile and mobile friendly Lightbox Gallery\n
\n Learn more\n
\n" + type: notice + link: 'https://getgrav.org/premium' + location: + - dashboard + - plugins + - themes + themes: + - + id: 27 + date: '2020-02-21 00:01' + message: "\n\nLoading...\n\n\n
\n
\n \n
\n
\n Turbo-charge your Grav site - from the creators of Grav\n Image Optimize - Optimize all the images on your Grav site\n Downloads Pro - Powerful download manager directly integrated with Grav\n Algolia Pro - Class-leading AI-powered search made easy for Grav\n SEO-Magic - Advanced SEO tool for Grav with automatic webshot generator\n Typhoon - The most powerful Grav theme ever built, based on Tailwind 3\n Cloudflare Manager - Configure and manage your domain right within the admin\n Lightbox Gallery - A light, versatile and mobile friendly Lightbox Gallery\n
\n Learn more\n
\n" + type: notice + link: 'https://getgrav.org/premium' + location: + - dashboard + - plugins + - themes diff --git a/grav-admin/user/pages/06.register/registration.md b/grav-admin/user/pages/06.register/registration.md index 58b48cd..7cd294e 100644 --- a/grav-admin/user/pages/06.register/registration.md +++ b/grav-admin/user/pages/06.register/registration.md @@ -1,4 +1,6 @@ --- title: Register +access: + onlyguests: true --- diff --git a/grav-admin/user/plugins/proxy-login/proxy-login.php b/grav-admin/user/plugins/proxy-login/proxy-login.php index d85febf..00b9b02 100644 --- a/grav-admin/user/plugins/proxy-login/proxy-login.php +++ b/grav-admin/user/plugins/proxy-login/proxy-login.php @@ -66,17 +66,14 @@ class ProxyLoginPlugin extends Plugin public function loadUser() { $this -> debug('Checking for user authentication...'); - print($_COOKIE['skouter']); - if (!array_key_exists("X-REMOTE-USER", $_SERVER)) { + if (!array_key_exists("HTTP_X_REMOTE_USER", $_SERVER)) { + $this -> grav['session'] -> skouter = null; return; } - $this -> grav['session'] -> user -> username = - $_SERVER["X-REMOTE-USER"]; - - print("hello"); - var_dump($_SERVER["X-REMOTE-USER"] ?? "didnt run"); + $this -> grav['session'] -> skouter = + $_SERVER["HTTP_X_REMOTE_USER"]; } public function debug($message) { diff --git a/grav-admin/user/themes/quark/templates/macros/macros.html.twig b/grav-admin/user/themes/quark/templates/macros/macros.html.twig index d11a20a..28c49be 100644 --- a/grav-admin/user/themes/quark/templates/macros/macros.html.twig +++ b/grav-admin/user/themes/quark/templates/macros/macros.html.twig @@ -1,6 +1,7 @@ {% macro nav_loop(page) %} {% import _self as macros %} - {% for p in page.children.visible %} + {% for p in page.children.visible + if (not p.header.access.onlyguests) and (not p.header.access.onlymembers)%} {% set active_page = (p.active or p.activeChild) ? 'active' : '' %}
  • @@ -13,4 +14,34 @@ {% endif %}
  • {% endfor %} -{% endmacro %} \ No newline at end of file + + {% for p in page.children.visible + if p.header.access.onlyguests and not grav.session.skouter %} + {% set active_page = (p.active or p.activeChild) ? 'active' : '' %} +
  • + + {{ p.menu }} {{p.header.access.onlyguests}} + + {% if p.children.visible.count > 0 %} + + {% endif %} +
  • + {% endfor %} + + {% for p in page.children.visible + if p.header.access.onlymembers and grav.session.skouter %} + {% set active_page = (p.active or p.activeChild) ? 'active' : '' %} +
  • + + {{ p.menu }} {{p.header.access.onlyguests}} + + {% if p.children.visible.count > 0 %} + + {% endif %} +
  • + {% endfor %} +{% endmacro %} diff --git a/skouter.go b/skouter.go index 1814d4f..c4db104 100644 --- a/skouter.go +++ b/skouter.go @@ -3753,12 +3753,9 @@ func setupProxy(r *httputil.ProxyRequest) { if claims.Valid() == nil { r.Out.Header.Set("X-REMOTE-USER", strconv.Itoa(claims.Id)) - log.Println(claims.Id) } else { r.Out.Header.Del("X-REMOTE-USER") } - - log.Println(err) } func serve() {