#4 - add support for sharing pages publicly, without login

This commit is contained in:
2021-03-04 11:26:14 -06:00
parent 2f3d94adf3
commit 82605bb697
8 changed files with 139 additions and 15 deletions

View File

@@ -16,14 +16,14 @@ class UserRoute extends Middleware {
* It should either call the next function in the stack,
* or it should handle the response accordingly.
*/
async test(req, res, next, args = {}){
async test(req, res, next, {allow_public_user = false}){
const User = this.models.get('auth:User')
const user_id = req.form.user_id ? req.form.user_id : req.params.user_id
if ( !user_id ) return res.status(400).message('Midding user_id.').api({})
const user = await User.findById(user_id)
if ( !user ) return res.status(404).message('Unable to find user with that ID.').api({})
if ( !user && !allow_public_user ) return res.status(404).message('Unable to find user with that ID.').api({})
if ( !req.form ) req.form = {}
req.form.user = user