Error reading 'uid' when Guest send post via form
-
Hello!
I created a form for send posts in topic, this is work but after submit the guest users redirect to
forum.com/compose
and view this:But the post is successful posted.
In the form body I was set this data
tid
,_csrf
and I try setuid
<input type="hidden" name="uid" value="8" />
But error for guest users saved, the authorized user don't have this error when submit a form and they redirected to topic
17
and not from user withuid 8
. How I can solved it?When try set
0
uid, not help...
-
@baris I enable socket&http logs in ACP:
io: 1 on [ { type: 2, nsp: '/', id: 43, data: [ 'admin.logs.get', null ] } ] io: 1 on [ { type: 2, nsp: '/', id: 43, data: [ 'admin.logs.get', null ] } ] io: 1 on [ { type: 2, nsp: '/', id: 43, data: [ 'admin.logs.get', null ] } ] io: 1 on [ { type: 2, nsp: '/', id: 43, data: [ 'admin.logs.get', null ] } ] io: 1 on [ { type: 2, nsp: '/', id: 43, data: [ 'admin.logs.get', null ] } ] io: 1 on [ { type: 2, nsp: '/', id: 43, data: [ 'admin.logs.get', null ] } ] When guest open page: 1.1.1.1 - - [20/Jun/2023:21:55:12 +0000] "GET / HTTP/1.1" 200 - "https://forum.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36" 1.1.1.1 - - [20/Jun/2023:21:55:13 +0000] "GET /assets/templates/500.js?_=1687298118918 HTTP/1.1" 200 - "https://forum.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36" 1.1.1.1 - - [20/Jun/2023:21:55:13 +0000] "GET /assets/templates/partials/toast.js?_=1687298118919 HTTP/1.1" 200 - "https://forum.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36" io: 0 emit [ 'checkSession', 0 ] io: 0 emit [ 'setHostname', 'X' ] 1.1.1.1 - - [20/Jun/2023:21:55:15 +0000] "GET /service-worker.js HTTP/1.1" 304 - "https://forum.com/service-worker.js" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36" io: 1 on [ { type: 2, nsp: '/', id: 54, data: [ 'admin.logs.get', null ] } ] io: 1 on [ { type: 2, nsp: '/', id: 54, data: [ 'admin.logs.get', null ] } ] io: 1 on [ { type: 2, nsp: '/', id: 54, data: [ 'admin.logs.get', null ] } ] io: 1 on [ { type: 2, nsp: '/', id: 54, data: [ 'admin.logs.get', null ] } ] io: 1 on [ { type: 2, nsp: '/', id: 54, data: [ 'admin.logs.get', null ] } ] io: 1 on [ { type: 2, nsp: '/', id: 54, data: [ 'admin.logs.get', null ] } ] After send form: 1.1.1.1 - - [20/Jun/2023:21:56:26 +0000] "POST /compose HTTP/1.1" 400 - "https://forum.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36" 1.1.1.1 - - [20/Jun/2023:21:56:27 +0000] "GET /assets/templates/partials/toast.js?_=1687298192453 HTTP/1.1" 200 - "https://forum.com/compose" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36" 1.1.1.1 - - [20/Jun/2023:21:56:27 +0000] "GET /assets/templates/500.js?_=1687298192452 HTTP/1.1" 200 - "https://forum.com/compose" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36" io: 0 emit [ 'checkSession', 0 ] io: 0 emit [ 'setHostname', 'X' ] io: 1 on [ { type: 2, nsp: '/', id: 15, data: [ 'notifications.getCount', null ] } ] io: 1 on [ { type: 2, nsp: '/', id: 15, data: [ 'notifications.getCount', null ] } ] io: 1 on [ { type: 2, nsp: '/', id: 15, data: [ 'notifications.getCount', null ] } ] io: 1 on [ { type: 2, nsp: '/', id: 15, data: [ 'notifications.getCount', null ] } ] io: 1 on [ { type: 2, nsp: '/', id: 4, data: [ 'notifications.getCount', null ] } ] io: 1 on [ { type: 2, nsp: '/', id: 4, data: [ 'notifications.getCount', null ] } ] io: 1 on [ { type: 2, nsp: '/', id: 4, data: [ 'notifications.getCount', null ] } ] io: 1 on [ { type: 2, nsp: '/', id: 4, data: [ 'notifications.getCount', null ] } ] io: 1 on [ { type: 2, nsp: '/', id: 4, data: [ 'notifications.getCount', null ] } ] io: 1 on [ { type: 2, nsp: '/', id: 4, data: [ 'notifications.getCount', null ] } ] io: 1 on [ { type: 2, nsp: '/', id: 55, data: [ 'notifications.getCount', null ] } ] io: 1 on [ { type: 2, nsp: '/', id: 55, data: [ 'notifications.getCount', null ] } ] io: 1 on [ { type: 2, nsp: '/', id: 55, data: [ 'notifications.getCount', null ] } ] io: 1 on [ { type: 2, nsp: '/', id: 55, data: [ 'notifications.getCount', null ] } ] io: 1 on [ { type: 2, nsp: '/', id: 55, data: [ 'notifications.getCount', null ] } ] io: 1 on [ { type: 2, nsp: '/', id: 55, data: [ 'notifications.getCount', null ] } ] 1.1.1.1 - - [20/Jun/2023:21:56:28 +0000] "GET /service-worker.js HTTP/1.1" 304 - "https://forum.com/service-worker.js" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36" io: 1 on [ { type: 2, nsp: '/', id: 56, data: [ 'admin.logs.get', null ] } ] io: 1 on [ { type: 2, nsp: '/', id: 56, data: [ 'admin.logs.get', null ] } ] io: 1 on [ { type: 2, nsp: '/', id: 56, data: [ 'admin.logs.get', null ] } ] io: 1 on [ { type: 2, nsp: '/', id: 56, data: [ 'admin.logs.get', null ] } ] io: 1 on [ { type: 2, nsp: '/', id: 56, data: [ 'admin.logs.get', null ] } ] io: 1 on [ { type: 2, nsp: '/', id: 56, data: [ 'admin.logs.get', null ] } ]
Post was successfully created, but guest redirect to page with error:
Cannot read properties of undefined (reading 'uid')
You can try reproduce it, this is template of the form for html widget + you need allow create posts for guest users in ACP setting.
<div class="card"><div class="card-body"> <form method="post" action="{config.relative_path}/compose"> <input type="hidden" name="tid" value="111" /> <input type="hidden" name="_csrf" value="{config.csrf_token}" /> <input type="text" class="form-control" name="content" placeholder="test"> <button type="submit" class="btn btn-sm btn-primary">Send</button> </form> </div></div>
-
Ok
I'm clear logs and rebuild forum to get fresh logs + guest send post via form.
2023-06-20T22:13:13.270Z [4567/32516] - [32minfo[39m: Initializing NodeBB v3.1.6 https://forum.com 2023-06-20T22:13:16.667Z [4567/32516] - [32minfo[39m: [socket.io] Restricting access to origin: https://forum.com:* 2023-06-20T22:13:17.414Z [4567/32516] - [33mwarn[39m: [plugins] File not found: /var/www/app/node_modules/nodebb-plugin-restrict-usernames/static/lib/main.js (Ignoring) 2023-06-20T22:13:17.415Z [4567/32516] - [33mwarn[39m: [plugins] File not found: /var/www/app/node_modules/nodebb-plugin-restrict-usernames/static/lib/acp-main.js (Ignoring) 2023-06-20T22:13:17.416Z [4567/32516] - [33mwarn[39m: [plugins] File not found: /var/www/app/node_modules/nodebb-plugin-restrict-usernames/static/lib/restrict-usernames.js (Ignoring) 2023-06-20T22:13:17.920Z [4567/32516] - [33mwarn[39m: [plugins/load] The following plugins may not be compatible with your version of NodeBB. This may cause unintended behaviour or crashing. In the event of an unresponsive NodeBB caused by this plugin, run `./nodebb reset -p PLUGINNAME` to disable it. * nodebb-rewards-essentials * nodebb-plugin-ns-slugify (node:32516) NOTE: We are formalizing our plans to enter AWS SDK for JavaScript (v2) into maintenance mode in 2023. Please migrate your code to use AWS SDK for JavaScript (v3). For more information, check the migration guide at https://a.co/7PzMCcy (Use `node --trace-warnings ...` to show where the warning was created) 2023-06-20T22:13:18.406Z [4567/32516] - [32minfo[39m: [api] Adding 2 route(s) to `api/v3/plugins` 2023-06-20T22:13:18.458Z [4567/32516] - [32minfo[39m: [router] Routes added 2023-06-20T22:13:23.463Z [4567/32516] - [33mwarn[39m: [plugins] Callback timed out, hook 'static:privileges.categories.init' in plugin 'nodebb-plugin-poll' 2023-06-20T22:13:23.467Z [4567/32516] - [32minfo[39m: 🎉 NodeBB Ready 2023-06-20T22:13:23.477Z [4567/32516] - [32minfo[39m: 🤝 Enabling 'trust proxy' 2023-06-20T22:13:23.480Z [4567/32516] - [32minfo[39m: 📡 NodeBB is now listening on: 0.0.0.0:4567 2023-06-20T22:13:23.493Z [4567/32516] - [32minfo[39m: 🔗 Canonical URL: https://forum.com WARNING: The keyword 'none' must be used as a single argument. ../../node_modules/bootstrap/scss/mixins/_box-shadow.scss 10:9 box-shadow() ../../node_modules/bootstrap/scss/forms/_form-control.scss 40:7 @import bootstrap/scss/_forms.scss 3:9 @import - 18:9 root stylesheet WARNING: The keyword 'none' must be used as a single argument. ../../node_modules/bootstrap/scss/mixins/_box-shadow.scss 10:9 box-shadow() ../../node_modules/bootstrap/scss/forms/_form-select.scss 31:7 @import bootstrap/scss/_forms.scss 4:9 @import - 18:9 root stylesheet
-
@baris said in Error reading 'uid' when Guest send post via form:
I don't see the crash there but I will take a look.
Thank you!
-