Yes you can use them inside the AMD module but keep in mind once you add an event listener on the window object it will be called everytime there is an action:ajaxify.end. If you don't want it triggered after you leave that page you need to turn it off with $(window).off('eventName', myMethod)
Plugin migration from 1.18 to 2.x -> Route.get() requires a callback function but got a [object Undefined]
-
Hi there,
I'm trying to migrate my forum to 2.8.2. I have an adapted sso plugin, that adds a GET route to find users by external oauth id.
The plugin works on 1.18 but breaks on 2.8.x already on startup.The error message is:
2023-01-19T22:37:12.434Z [4567/458] - error: [plugins] Error executing 'static:app.load' in plugin 'nodebb-plugin-sso-oauth-faforever' Error: Route.get() requires a callback function but got a [object Undefined] at Route.<computed> [as get] (/usr/src/app/node_modules/express/lib/router/route.js:211:15) at proto.<computed> [as get] (/usr/src/app/node_modules/express/lib/router/index.js:521:19) at OAuth.load (/usr/src/app/node_modules/nodebb-plugin-sso-oauth-faforever/library.js:91:10)
The code in question is here:
https://github.com/FAForever/nodebb-plugin-sso-oauth-faforever/blob/ec80064334c0e7a210e9ba5b324bd80d17f5a0c9/library.js#L91router.get('/api/user/oauth/:externalUserId', middleware.authenticateOrGuest, async function (req, res, next) { const userId = await db.getObjectField(constants.name + 'Id:uid', req.params.externalUserId); if (!userId) { return next(); } const userData = await userController.getUserDataByUID(req.uid, userId);
I compared to other route.get and also other plugins and even our project express page, but I don't understand where the error could. I tried removing the async but no success. I also googled the error in general, but it doesn't make me much smarter.
Any help is appreciated.
-
See this topic for breaking changes in 1.19.0 https://community.nodebb.org/post/86172. You can rename
middleware.authenticateOrGuest
tomiddleware.authenticateRequest