Hi guys, the idea is following:
I want to catch any modification on entity and write it in another log entity using lifecycles.js.
The problem I don’t know how to retrieve the user ID who made this request, if it modified from UI so OK, I have his ID but if he makes a modification from my next.js application so I don’t have this ID.
any ideas?
My code:
beforeUpdate: async ({params}) => {
//--- insert log ---
try{
const diff = await getUpdateDifferences(params);
const action = "Modified";
const message = "Affected fields: " + JSON.stringify(diff);
const entry = await strapi.db.query('api::log.log').create({
action: action,
message: message,
user: ???????
})
}catch(error){
console.log('ERROR:', error)
}
},