我希望更新身份验证中的 firebase 电子邮件。更新电子邮件后,如果我检查 Firebase 身份验证,我希望看到新电子邮件。下次当我尝试登录时,我可以使用新电子邮件登录,但可以使用旧密码。有可能吗(如果有的话)?
您可以使用 Firebase Admin SDK 修改现有用户的数据,包括其电子邮件,请参阅 文档。
因此,使用用户 uid 和新电子邮件,您将执行以下操作:
getAuth()
.updateUser(uid, {
email: '[email protected]'
})
.then((userRecord) => {
// See the UserRecord reference doc for the contents of userRecord.
console.log('Successfully updated user', userRecord.toJSON());
})
.catch((error) => {
console.log('Error updating user:', error);
});
上面的代码是 Node.js 代码,您可以在 Cloud Function 中运行,甚至可以作为计算机上的 Node.js 脚本运行。