Hello there!
I am currently trying to figure out the best way to have auth0 ping the create method of my user API in my NESTJS service. the issue I’m having is that my create method has a authGaurd(‘jwt’) associated with it, so if a create a hook that pings it, it wont have a bearer token in the header to give it access, it takes the users name, email and sub from the JWT passed in the header. I’m sure this is a common enough thing to try to implement, but I have been struggling to follow the docs. If anyone has any clarity around the best way to do this that would be incredible help full, for reference, this is my create method in my user service: `
@UseGuards(AuthGuard('jwt'))
@Post()
create(@User() user): Promise<UserEntity> {
const createUserDto: CreateUserDto = {
name: user.name,
email: user.email,
sub: user.sub,
isRegistered: true,
};
//return 'success';
return this.userService.create(createUserDto);
}`
and this is what I currently have as a hook in Auth0:
module.exports = function (user, context, cb) {
// Perform any asynchronous actions, e.g. send notification to Slack.
const axios = require("axios");
/**
* @param {Event} event - Details about registration event.
*/
exports.onExecutePostUserRegistration = async (event) => {
await axios.post("http://localhost:8000/user", {
params: {
name: event.user.name,
email: event.user.email,
sub: event.user.id,
}
});};
cb();
};
type or paste code here