Hi, I would like to rebuild the app including some modification to a file in order to disable the search feature for anonymous users.(more than with just css)
Can anyone provide me some documentation for the syntax of those hooks for the from: & to: part?
- replace:
filename: "/var/www/discourse/app/assets/javascripts/discourse/app/components/search-menu.js"
from: /get classNames()/
to: |
if (!this.currentUser) {return false;} get classNames()
Discourse accepts the syntax now but at the end of the rebuild it fails with
Error: Parse Error at discourse/components/search-menu.gjs:88:7"
replace failed with the params {"filename"=>"/var/www/discourse/app/assets/javascripts/discourse/app/components/search-menu.gjs", "from"=>"/get classNames()/", "to"=>"if (!this.currentUser) {return false;} get classNames()\n"}
Thanks for pointing that out. Just to clarify, what’s the name of the hidden site setting? And does it fully disable search for anonymous users, or just hide the results? I’m looking for a way to block access at the controller level, so wondering if that setting alone is enough or if some custom code is still needed.
Now the /search page is unreachable = great
Now the front end search button instantly returns : you’ve performed this action too many times = great
You may hide the search button with :
But the question is : is this thorough? Can anyone just create a simple session cookie to make it look like they are connected so that they can access the content of the site through searches?
More thorough but uncomplete solution :
The file is : /var/www/discourse/app/controllers/search_controller.rb
The modification : add “if current_user.present?” after “def show” and add an “end” at the bottom of the condition.
However I could not make it persistent after restart, so anybody is welcome to tell how to make it persistent after restart with the app.yml hooks after_code replace: feature.
I mean non logged in user that would create a session cookie to pretend they are logged in but maybe I am fetching a bit too far here as I guess that the currentUser function checks the session key.
" That would be a security issue. If you can achieve that make sure to report to HackerOne"
No, I am new to discourse, I cannot even quote properly , I was just asking, maybe there was some discourse engineer around ; anyway, we got our solution to this thread thanks to you Falco