admin firebase 错误:"admin.auth(...).generatePasswordResetLink is not a function"
Error with admin firebase: "admin.auth(...).generatePasswordResetLink is not a function"
我通过 Node.js(nodemailer) 和 firebase 制作了电子邮件服务。
当我在应用程序中创建新用户时,该新用户应该会收到欢迎电子邮件 Link 用于重设密码。
现在我需要将 firebase admin --generatePasswordResetLink 实施到 node.js
In this line of code is problem, errors is that generatePasswordResetLink() is not a function:
admin.auth().generatePasswordResetLink(user.email, actionCodeSettings)
// Create user
async function createUser(user) {
firebase
.auth()
.createUser({
email: user.email,
password: user.password,
displayName: `${user.firstName} ${user.lastName}`
})
// After user is created make a email teamplate and send it
.then(function(userRecord) {
let resetLink = ''
// Welcome email template
const output = `
<p>You have access to the Church Mutual Assignment Tool.</p>
<p>Follow this link to create new password for your account ${userRecord.email}:</p>
<p>${this.resetLink}</p>
<p>Thanks,</p>
<p>Your Church Mutual Assignment Tool team</p>
`
let message = {
from: 'nyik6nntutmq3vz6@ethereal.email',
to: `${user.email}`,
subject: 'Welcome to the Church Mutual Assignment Tool',
text: 'Plaintext version of the message',
html: output
}
// Generate reset password and Send Email
//===== HERE IS PROBLEM THIS generatePasswordResetLink() "is not a fucntion"====== \
admin.auth().generatePasswordResetLink(user.email, actionCodeSettings)
.then(link => {
// Send Email
transport.sendMail(message, (err, info) => {
if (err) throw new Error('Error with email', err)
})
return sendCustomPasswordResetEmail(user.email, user.displayName, link)
})
.catch(error => {
console.log('error', error)
})
})
}
您很可能使用的 Node.js Admin SDK 版本低于 6.2.0。
在此处查看 Firebase Admin Node.js SDK 发行说明:https://firebase.google.com/support/release-notes/admin/node。 "email action link generation APIs for creating links for password reset, email verification and email link sign-in" 是在 2018 年 11 月才添加的,版本为 6.2.0。
我通过 Node.js(nodemailer) 和 firebase 制作了电子邮件服务。
当我在应用程序中创建新用户时,该新用户应该会收到欢迎电子邮件 Link 用于重设密码。
现在我需要将 firebase admin --generatePasswordResetLink 实施到 node.js
In this line of code is problem, errors is that generatePasswordResetLink() is not a function:
admin.auth().generatePasswordResetLink(user.email, actionCodeSettings)
// Create user
async function createUser(user) {
firebase
.auth()
.createUser({
email: user.email,
password: user.password,
displayName: `${user.firstName} ${user.lastName}`
})
// After user is created make a email teamplate and send it
.then(function(userRecord) {
let resetLink = ''
// Welcome email template
const output = `
<p>You have access to the Church Mutual Assignment Tool.</p>
<p>Follow this link to create new password for your account ${userRecord.email}:</p>
<p>${this.resetLink}</p>
<p>Thanks,</p>
<p>Your Church Mutual Assignment Tool team</p>
`
let message = {
from: 'nyik6nntutmq3vz6@ethereal.email',
to: `${user.email}`,
subject: 'Welcome to the Church Mutual Assignment Tool',
text: 'Plaintext version of the message',
html: output
}
// Generate reset password and Send Email
//===== HERE IS PROBLEM THIS generatePasswordResetLink() "is not a fucntion"====== \
admin.auth().generatePasswordResetLink(user.email, actionCodeSettings)
.then(link => {
// Send Email
transport.sendMail(message, (err, info) => {
if (err) throw new Error('Error with email', err)
})
return sendCustomPasswordResetEmail(user.email, user.displayName, link)
})
.catch(error => {
console.log('error', error)
})
})
}
您很可能使用的 Node.js Admin SDK 版本低于 6.2.0。
在此处查看 Firebase Admin Node.js SDK 发行说明:https://firebase.google.com/support/release-notes/admin/node。 "email action link generation APIs for creating links for password reset, email verification and email link sign-in" 是在 2018 年 11 月才添加的,版本为 6.2.0。