简体   繁体   English

如何通过 getUserByPhoneNumber 使用 google-cloud firestore 身份验证获取用户记录?

[英]How to get the user Record using the google-cloud firestore auth by getUserByPhoneNumber?

I have to extract data from the user using auth by phone Number.我必须通过电话号码使用身份验证从用户那里提取数据。 I have an array of user's phone number.我有一组用户的电话号码。

I have written a solution and it gives the required output but it doesn't terminate.我写了一个解决方案,它提供了所需的输出,但它不会终止。 How can I solve this problem?我怎么解决这个问题?

"phoneNumberArray" is the array of user's phone number. “phoneNumberArray”是用户电话号码的数组。 It is mostly related to HTTP background trigger functions.I have solved this but this is a firebase issue so please see this它主要与 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}

I have used this way to solve the function.我已经使用这种方式来解决该功能。

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)}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Firestore 在 google-cloud firestore 上查询“IN” - Firestore where 'IN' query on google-cloud firestore 用于导出 Firestore 备份数据的云功能。 使用 firebase-admin 还是 @google-cloud/firestore? - Cloud function to export Firestore backup data. Using firebase-admin or @google-cloud/firestore? 如何使用Google PubSub(@ google-cloud / pubsub)进行确认 - How to ACK using Google PubSub (@google-cloud/pubsub) 如何使用玩笑模拟@google-cloud/kms - How to mock @google-cloud/kms using jest 如何使用 nodejs 在云 Firestore 中检索用户身份验证信息? - How to retrieve user auth information in cloud firestore using nodejs? 使用 node.js 标准环境在 AppEngine 上找不到模块 @google-cloud/firestore - Cannot find module @google-cloud/firestore on AppEngine using node.js standard environment @google-cloud/redis 获取和设置未找到 - @google-cloud/redis get and set not found 在Firestore Cloud功能中通过其uid获取身份验证用户 - Get a auth user by its uid in Firestore cloud function 如何使用@google-cloud/logging 发送带有文本消息和 JSON 有效负载的单个日志条目? - How to send a single log entry with a text message and a JSON payload using @google-cloud/logging? 如何使用nodejs google-cloud / compute工具从快照在GCP上创建VM实例 - How to create a VM instance on GCP from a snapshot using the nodejs google-cloud/compute tool
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM