const functions = require('firebase-functions');
const nodemailer = require('nodemailer');
const admin = require('firebase-admin');
//
var serviceAccount = require("-----");
//
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "---"
});
const uid = '--uid--'
admin.auth().updateUser(uid, {
email: '--new email--'
})
.then(function(userRecord) {
// See the UserRecord reference doc for the contents of userRecord.
console.log('Successfully updated user', userRecord.toJSON());
})
.catch(function(error) {
console.log('Error updating user:', error);
});
exports.sendWelcomeEmail = functions.auth.user().onCreate((user) => {
const email = user.email;
const displayName = user.displayName;
return sendWelcomeEmail(email, displayName);
});
// SEND WELCOME email
function sendWelcomeEmail(email, displayName) {
const mailOptions = {
from: '--- <noreply@firebase.com>',
to: email
};
mailOptions.subject = '---';
mailOptions.text = '---';
return mailTransport.sendMail(mailOptions).then(() => {
console.log('Welcome email sent to:', email);
});
}
I had been using this to update users' email addresses for the past few years, but just today I tried again and the function is not running. I have other cloud functions in the same file that still runs, they have triggered events such as welcome Emails, but this function is no longer running. Any idea what might have changed? or why is it no longer working?