System Information
- Strapi Version:
- Operating System:
- Database:
- Node Version:
- NPM Version:
- Yarn Version:
Is there any way to extend an existing method of a controller? i.e. I would like to extend the register method of the users-permissions plugin.
I tried the following approach:
-
I created a new auth.js file in extensions/users-permissions/controllers
-
I created a routes.json in its config folder
-
I set the content of auth.js to this:
module.exports = {
async registerExt(ctx) {
console.log(“Custom auth”)
strapi.plugins[‘users-permissions’].controllers.auth.register(ctx)
.then(res => {
console.log(res)
strapi.services.email.sendSignup(res.user_id.email, ‘’);
})
.catch(e => {
console.log(e)
return e
})
}
}
But I can see that res is always undefined, thus I cannot get anything out of the return value of the original register() call. It would be nice if I could overrider the register() functions directly. I tried but then the content of strapi.plugins[‘users-permissions’].controllers.auth.register is my own function, which leads to an infinite loop
Cheers!