Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: filter:account/profile.build hook passes in different object #59

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

barisusakli
Copy link
Contributor

filter:account/profile.build is passed an object with req, res and templateData. Template data has the user info. Without this change the code crashes with

TypeError: Cannot read properties of undefined (reading 'uid')
    at /home/saas/nodebb/node_modules/nodebb-plugin-ns-awards/plugin/controller.js:193:54
    at nextTask (/home/saas/nodebb/node_modules/async/dist/async.js:5789:13)
    at next (/home/saas/nodebb/node_modules/async/dist/async.js:5797:13)
    at /home/saas/nodebb/node_modules/async/dist/async.js:327:20
    at Settings.get (/home/saas/nodebb/node_modules/nodebb-plugin-ns-awards/plugin/settings.js:60:16)
    at /home/saas/nodebb/node_modules/async/dist/async.js:53:33
    at nextTask (/home/saas/nodebb/node_modules/async/dist/async.js:5789:13)
    at Object.waterfall (/home/saas/nodebb/node_modules/async/dist/async.js:5800:9)
    at Object.awaitable [as waterfall] (/home/saas/nodebb/node_modules/async/dist/async.js:211:32)
    at Object.Controller.getAccountWithRewards (/home/saas/nodebb/node_modules/nodebb-plugin-ns-awards/plugin/controller.js:186:15)
    at Object.Filter.account [as method] (/home/saas/nodebb/node_modules/nodebb-plugin-ns-awards/plugin/filters.js:15:20)
    at /home/saas/nodebb/src/plugins/hooks.js:171:29

filter:account/profile.build is passed an object with req, res and templateData. Template data has the user info. Without this change the code crashes with 

```
TypeError: Cannot read properties of undefined (reading 'uid')
    at /home/saas/nodebb/node_modules/nodebb-plugin-ns-awards/plugin/controller.js:193:54
    at nextTask (/home/saas/nodebb/node_modules/async/dist/async.js:5789:13)
    at next (/home/saas/nodebb/node_modules/async/dist/async.js:5797:13)
    at /home/saas/nodebb/node_modules/async/dist/async.js:327:20
    at Settings.get (/home/saas/nodebb/node_modules/nodebb-plugin-ns-awards/plugin/settings.js:60:16)
    at /home/saas/nodebb/node_modules/async/dist/async.js:53:33
    at nextTask (/home/saas/nodebb/node_modules/async/dist/async.js:5789:13)
    at Object.waterfall (/home/saas/nodebb/node_modules/async/dist/async.js:5800:9)
    at Object.awaitable [as waterfall] (/home/saas/nodebb/node_modules/async/dist/async.js:211:32)
    at Object.Controller.getAccountWithRewards (/home/saas/nodebb/node_modules/nodebb-plugin-ns-awards/plugin/controller.js:186:15)
    at Object.Filter.account [as method] (/home/saas/nodebb/node_modules/nodebb-plugin-ns-awards/plugin/filters.js:15:20)
    at /home/saas/nodebb/src/plugins/hooks.js:171:29

```
@Frozen-byte
Copy link

works like a charm for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants