node.js - 如何通过getUserByPhoneNumber使用google-cloud firestore auth获取用户记录?
问题描述
我必须通过电话号码使用身份验证从用户那里提取数据。我有一组用户的电话号码。
我已经编写了一个解决方案,它提供了所需的输出,但它不会终止。我怎么解决这个问题?
“phoneNumberArray”是用户电话号码的数组。它主要与HTTP后台触发功能有关。我已经解决了这个问题,但这是一个firebase问题,所以请看这个
const user = async () => {
const getAuth = async phoneNumber => {
return auth.getUserByPhoneNumber(phoneNumber).catch(() => {
return {
phoneNumber,
uid: null,
email: '',
displayName: '',
emailVerified: false,
disabled: false,
};
});
};
const userRecord = await Promise.all(
phoneNumberArray.map(phoneNumber => {
return getAuth(phoneNumber);
}),
);
//when i console.log(userRecord) it's print the output
const x = {
'userRecord Length': userRecord.length
}
console.log(x)
return;
}
module.exports = {user}
解决方案
我已经使用这种方式来解决该功能。
in the main file i have to return
return x,admin;
and the calling file works like this
const {user} = require('./filename');
user().then(e => {
console.log(e.x)
e.admin.apps[0].delete();
})catch(error){
console.log(error)}
推荐阅读
- python - 防止我的 RAM 内存达到 100%
- vb.net - 在沙特阿拉伯和美国之间转换 CultureInfo 货币
- python - 删除 tkinter 中的条目小部件
- python - 控制 Selenium (Python) 浏览器对网页显示的设备
- ruby-on-rails - 不正确的控制器结构不允许多个操作
- node.js - 使用带有 Node.js 的 TypeScript,如何将“import”语句转换为“require”语句?
- c# - 按父 ID 对列表元素进行分组,然后按另一个字段排序
- ios - Swift iOS - 如何在 Firebase TransactionBlock 上放置计时器以防止它在特定时间段内增加
- java - 错误:表达式和“;”的非法开始 预期的
- javascript - 如何从 ES 中的字符串确定文件大小?