如何构建自定义 Firebase 注册确认/验证/电子邮件重置
How to build a custom Firebase registration confirmation / validation / email reset
这让我彻底疯了。
我无法使用 firebase 电子邮件系统通知用户有关帐户验证电子邮件、电子邮件重置或电子邮件更改的信息,因为我无法更改语言或模板。所以我开始使用 Sparkpost。
我已经构建了它的大部分功能,但我发现我无法获取此操作的确认码。
有没有办法在不使用电子邮件系统的情况下使用这些功能?我能以任何方式获得执行所需的 "code":
[confirmPasswordReset(code, newPassword)][3]
[checkActionCode(code)][2]
[applyActionCode(code)][1]
如果我能以任何方式获得此代码,我可以混合使用 sparkpost 邮件系统和 angular 页面来验证用户或更改我的离子应用程序的密码。或者我可以制作一个节点端点来执行此操作。
我真的需要一些帮助。
您无法通过publicAPI获取验证码。
但是您可以通过使用 Firebase Admin SDK 直接在服务器端代码中验证用户帐户(无需调用 checkActionCode
/applyActionCode
) Node.js.
来自documentation on updating a user:
The updateUser()
method allows you to modify an existing user's data. It accepts a uid
for the user to update as well as an object containing the UserRecord
properties to update:
admin.auth().updateUser(uid, {
email: "modifiedUser@example.com",
emailVerified: true,
password: "newPassword",
displayName: "Jane Doe",
photoURL: "http://www.example.com/12345678/photo.png",
disabled: true
})
.then(function(userRecord) {
console.log("Successfully updated user", userRecord.toJSON());
})
.catch(function(error) {
console.log("Error updating user:", error);
});
有了这个,您可以建立自己的验证机制,然后在完成后简单地更新用户的状态。
这让我彻底疯了。 我无法使用 firebase 电子邮件系统通知用户有关帐户验证电子邮件、电子邮件重置或电子邮件更改的信息,因为我无法更改语言或模板。所以我开始使用 Sparkpost。 我已经构建了它的大部分功能,但我发现我无法获取此操作的确认码。
有没有办法在不使用电子邮件系统的情况下使用这些功能?我能以任何方式获得执行所需的 "code":
[confirmPasswordReset(code, newPassword)][3]
[checkActionCode(code)][2]
[applyActionCode(code)][1]
如果我能以任何方式获得此代码,我可以混合使用 sparkpost 邮件系统和 angular 页面来验证用户或更改我的离子应用程序的密码。或者我可以制作一个节点端点来执行此操作。
我真的需要一些帮助。
您无法通过publicAPI获取验证码。
但是您可以通过使用 Firebase Admin SDK 直接在服务器端代码中验证用户帐户(无需调用 checkActionCode
/applyActionCode
) Node.js.
来自documentation on updating a user:
The
updateUser()
method allows you to modify an existing user's data. It accepts auid
for the user to update as well as an object containing theUserRecord
properties to update:admin.auth().updateUser(uid, { email: "modifiedUser@example.com", emailVerified: true, password: "newPassword", displayName: "Jane Doe", photoURL: "http://www.example.com/12345678/photo.png", disabled: true }) .then(function(userRecord) { console.log("Successfully updated user", userRecord.toJSON()); }) .catch(function(error) { console.log("Error updating user:", error); });
有了这个,您可以建立自己的验证机制,然后在完成后简单地更新用户的状态。