I have an onUpdate triger on my users collection that updates the corresponding user profile.
exports.onUpdateUser = functions.firestore.document('/users/{uid}')
.onUpdate((change, context) => {
const { uid } = context.params;
const { email, displayName, photoURL } = change.after.data();
return admin.auth().updateUser(uid, {
email,
displayName,
photoURL
});
});
The trigger may throw an error if the email provided already exists. In this case, I want to discard the changes made to the user document and then let the client know about that error.
With the above implementation, the document would be updated successfully and the trigger would throw an error silently, without the client knowing this.
Can I change this behavior or my only option is implementing a separate HTTP cloud function for handling user updates?