响应本机Firebase身份验证搜索 [英] React native firebase authentication searching

查看:59
本文介绍了响应本机Firebase身份验证搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个可搜索的字段,该字段在firebase应用程序中搜索已注册的用户并返回所有紧密匹配项的列表.原因是我需要找到搜索到的用户uid以邀请他们加入游戏,然后传递推送通知以提醒他们已收到邀请.我不知道这是否可行,因为文档似乎暗示它必须与电子邮件地址进行1对1匹配才能返回.

I'm trying to create a searchable field that searches the registered users in the firebase application and return a list of all close matches. The reason for this is I need to find the searched users uid to invite them to a game, and then deliver a push notification to alert them that an invite has been recieved. I don't know if this is possible as the documentation seems to suggest it has to be a 1 to 1 match against the email address for it to be returned.

我遇到的问题是firebase-admin中的admin.auth()要求节点模块执行相关工作.因此,我想知道是否还有另一个SDK允许您执行此操作,或者可以使用react native expo应用程序中的标准firebase导入来产生此功能.

The problem I'm experiencing is the admin.auth() from firebase-admin requires node modules to perform the related work. So I'm wondering if there is another SDK that allows you to do so or can this functionality be produced using the standard firebase import in a react native expo application.

不幸的是,我没有代码,因为似乎没有任何工作,并且都指向在基于节点的项目中使用firebase-admin软件包来完成查询的肮脏工作.

Unfortunately, I have no code as nothing seems to work and all point to using the firebase-admin package in a node-based project to do the dirty work of the query.

对此有任何帮助,将不胜感激.

Any help on this one would be appreciated.

推荐答案

仅通过客户端SDK(例如用于React Native的SDK)无法搜索所有Firebase身份验证用户.允许这样做将带来很大的安全风险.

There is no way to search across all Firebase Authentication users with just a client-side SDK like the one for React Native. Allowing that would be a pretty big security risk.

有两种常用方法可以安全地搜索用户:

There are two common approaches to allow searching the users in a secure way:

  1. 在每个用户注册时将有关每个用户的信息写入数据库(例如Cloud Firestore或实时数据库),然后在需要时搜索数据库.这样,您的代码可以控制要写入的数据并可以进行搜索.

  1. Write information about each user to a database (such as Cloud Firestore or the Realtime Database) when they register, and then search the database when needed. That way your code controls what data gets written and thus is searchable.

Firebase具有可在受信任环境(例如开发计算机,您控制的服务器或云功能)中运行的Admin SDK.这些SDK具有列出用户的选项,这意味着您可以搜索他们.如果将其中一个Admin SDK封装在自己构建并保护自己的自定义API中,则可以从应用程序代码中调用它.

Firebase has Admin SDKs that run in trusted environments, such as your development machine, a server you control, or Cloud Functions. These SDKs have options to list users, which means you can search them. If you wrap one of the Admin SDKs in a custom API that you build and secure yourself, you can then call that from your application code.

这篇关于响应本机Firebase身份验证搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆