每个设备摇动一个帐户 [英] Flutter one account per device

查看:62
本文介绍了每个设备摇动一个帐户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使一个帐户中只有一个用户出现在应用程序中?我使用Flutter + Firebase身份验证(电子邮件和密码)例如,我有一个帐户,只有我可以从我的设备登录.如果有人发现了我的帐户,他将无法登录谢谢!

How to make so that under one account came only one user in the application? I use flutter + firebase auth (email and passsword) For example, I have an account and only I can log in from my device. if someone found out my account, he would not be able to log in Thank you!

推荐答案

我只是给您一个方法.

  1. 在Cloud Firestore中,创建一个名为 device_ids 的集合.

当用户尝试登录时,请检查您的手机的设备ID(例如 9876543210 )是否作为文档ID存在于您的集合 device_ids 中.

When a user tries to log in, check if device ID (let's say 9876543210) of his phone is present as document ID in your collection device_ids.

如果否,请使用该设备ID创建一个文档ID,并在此文档ID中创建一个 email 字段,并将给定的电子邮件ID放在此处,并允许用户注册.

If no, create a document ID with this device ID and in this document ID, create a email field and put given email ID here and allow user to sign up.

如果是,请转到特定的文档ID(此处为 9876543210 )并获取 email (即 hello@email.com ).现在,检查用户是否输入了此电子邮件,允许他登录,否则告诉他该设备已注册了提取的电子邮件ID,并且需要使用电子邮件ID登录.

If yes, go to the particular document ID (9876543210 here) and fetch the email (which is hello@email.com). Now check if user entered this email, allow him to log in else tell him the fetched email ID is already registered for this device and he needs to sign in with email ID.

希望有帮助!

这篇关于每个设备摇动一个帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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