javascript - 为什么我的 firebase 云功能会运行多次?
问题描述
我为 Firebase 管理员编写了一个云功能。这是重置用户的密码。它传入用户 UID 和新通行证,但是当我运行该函数时,它不仅重置了该用户的密码,还为每个用户设置了密码。数据库中的每个用户。
下面是调用该函数的代码:
resetForm.addEventListener('submit', (e) => {
e.preventDefault();
let newPass = resetForm['reset-password'].value;
const resetPasswordFunction = firebase.functions().httpsCallable('resetPassword');
resetPasswordFunction({docId: docId, newPass: newPass}).then(() => {
const modal = document.querySelector('#modal-reset');
M.Modal.getInstance(modal).close();
resetForm.reset();
});
});
这是功能:
var functions = require('firebase-functions');
var admin = require("firebase-admin");
var serviceAccount = require("./troop-30-elections-web-app-firebase-adminsdk-obsmr-61cc4bb59e.json");
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "https://troop-30-elections-web-app.firebaseio.com"
});
exports.resetPassword = functions.https.onCall((data) => {
return admin.auth().updateUser(data.docId, {
password: data.newPass
})
.then(() => {
return {"text": "User Password Successfully Updated"}; // this is what gets sent back to the app
});
});
解决方案
推荐阅读
- rest - 内容类型'application/json;charset=UTF-8' 不支持 Spring Boot REST API
- maxscript - Maxscript - 如何在 3ds Max 2020 中将渲染更改为纹理输出目录?
- html - MS Outlook 2013 (Windows 7) 中图像周围的奇怪框架
- algorithm - 如何使用 2D 表最大化棒材切割的产品?
- dependency-injection - 服务中的导入 dart:html 出现异常 找不到动态提供程序
- javascript - 我有一个数字数组。我需要返回一个新数组,其中重复的数字在它们自己的嵌套数组中
- c# - 确定独特的构建
- python-3.x - For循环将网页抓取的数据写入excel不会超过第一个链接
- maven - 将凭据从 Jenkins 传递给 Maven
- javascript - 如何等待另一个承诺填充的数组