[docs] Allow pages to not use require_login #1416
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Need
I think it should be possible (and not violate recommendations) to create a Moodle plugin that has a public web page. No login. No access checks whatsoever. No dependency on turning on Guest User. No dependency on turning Guest User access to the course with id=1. No other dependencies whatsoever.
If you care, a specific use case is documented below (“USE CASE”), but that is not germane to the discussion. And please do not shut down this discussion if you disagree with that specific use case.
Problems
The documentation page for
require_login(...)
specifies that:I disagree with this because of the reasons above.
Solution
I propose one of two alternative solutions:
a) Update that documentation to state the following:
-or-
b) Add a new function called
do_not_require_login(...)
which does what I am describing above in “a)” (which may or may not do logging and associate this page access with the course, if provided). And also update the “should includerequire_login()
orrequire_course_login()
" prescription with “ordo_not_require_login(...)
".Use case
The imminent use case is that we have course completion certificates in Moodle. These certificates will have a QR code on them. And we are implementing that a visitor can scan these QR codes (on mobile) without logging in.
The people that are scanning/verifying these certificates care that the student has completed the course, and they do not care about logging in. And we do not care about them logging in.
Testing Instructions
The RequireLoginSniff, part of the Moodle Code Checker is now requiring the
require_login()
function on every page because of the documentation isssue above.Automated test results
None
Pre-check results
None
Workaround
None
Other notes
This all-important
require_login(...)
function has some problems: