Jam*_*ney 1 node.js firebase firebase-authentication firebase-admin
我通过Node.js(nodemailer)和firebase制作了一个电子邮件服务.
当我在应用程序中创建新用户时,该新用户应该收到带有链接重新密码的欢迎电子邮件.
现在我需要在node.js中实现firebase admin --generatePasswordResetLink
在这行代码中存在问题,错误是generatePasswordResetLink()不是函数:
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)
})
})
}
Run Code Online (Sandbox Code Playgroud)
您最有可能使用<Version 6.2.0的Node.js Admin SDK版本.
请在此处查看Firebase Admin Node.js SDK发行说明:https://firebase.google.com/support/release-notes/admin/node.用于创建密码重置,电子邮件验证和电子邮件链接登录链接的"电子邮件操作链接生成API"仅在2018年11月添加,版本为6.2.0.
| 归档时间: |
|
| 查看次数: |
342 次 |
| 最近记录: |