简体   繁体   English

如果用户删除了应用程序或更换了手机,如何恢复用户帐户?

[英]How to recover user account if user has deleted the app or changed phone?

I am working with Cloud Firestore and I came to the question on the top.我正在与 Cloud Firestore 合作,我来到了最上面的问题。 I will set you an example我会给你一个榜样

  1. The user installs the app and log's in with Google.用户安装应用程序并使用 Google 登录。 I save the log-in information in the device storage so the user does not have to log in every time.我将登录信息保存在设备存储中,因此用户不必每次都登录。 It is also stored in Firestore with a generated ID.它还使用生成的 ID 存储在 Firestore 中。
  2. The user plays with the app and one day uninstalls it.用户使用该应用程序并有一天将其卸载。 This erases the log-in information in the async storage, losing the generated ID that granted him access to the app.这会删除异步存储中的登录信息,丢失授予他访问应用程序的生成 ID。
  3. One day he decides to install it again, let's say in another device to make it harder.有一天他决定重新安装它,让我们说在另一台设备上让它变得更难。 He had various information in his profile or maybe an active payment plan he forgot to delete and he wants to do it now.他的个人资料中有各种信息,或者可能是他忘记删除的有效付款计划,他现在想这样做。 He clicks on google log in since it was how he did it, but now the profile information is gone because another account was created with another generated ID.他点击 google 登录,因为他是这样做的,但现在个人资料信息消失了,因为另一个帐户是使用另一个生成的 ID 创建的。

How to avoid this?如何避免这种情况? I want the app to remember the user account in some way.我希望应用程序以某种方式记住用户帐户。 The user account would be stored in my Firestore.用户帐户将存储在我的 Firestore 中。

According to the docs :根据文档

  • For Android and iOS, offline persistence is enabled by default. Android和iOS默认开启离线持久化。

Meaning that by default, Firestore creates a locate copy of the database on the client's device.这意味着默认情况下,Firestore 在客户端设备上创建数据库的定位副本。

User installs app and log's in with Google.用户安装应用程序并使用 Google 登录。

So I assume you have already implemented Firebase authentication with Google .所以我假设您已经使用 Google 实现了 Firebase 身份验证

It is also stored in Firestore with a generated ID.它还使用生成的 ID 存储在 Firestore 中。

Without seeing that "generated ID", it's hard to say if it's the correct ID or not.如果没有看到那个“生成的 ID”,很难说它是否是正确的 ID。 The idea behind this authentication is to sign-in your users with Firebase, no matter what the provider is.此身份验证背后的想法是使用 Firebase 登录您的用户,无论提供者是什么。 Furthermore, if you want to save user data in Firestore, store it into a document whose id is the user ID that comes from the authentication process.此外,如果您想将用户数据保存在 Firestore 中,请将其存储到一个文档中,该文档的 id 是来自身份验证过程的用户 ID。 In this way, doesn't matter what the provider is, you'll always store the data under a document whose key will never change.这样,无论提供者是什么,您都将始终将数据存储在其密钥永远不会更改的文档下。

User plays with the app and one day uninstalls it.用户使用该应用程序并有一天将其卸载。 This erases the log-in information in the async storage, losing the generated ID that granted him access to the app.这会删除异步存储中的登录信息,丢失授予他访问应用程序的生成 ID。

It's true that if the user uninstalls the app, all the cache is wiped out from the storage, including the log-in information.确实,如果用户卸载应用程序,所有缓存都会从存储中清除,包括登录信息。 That being said, bear in mind that you should never store such information on the disk.话虽如此,请记住,您永远不应该将此类信息存储在磁盘上。 When using Firebase authentication , there is no log-in information that needs to be stored.使用Firebase 认证时,没有需要存储的登录信息。 If you didn't still implement it, I recommend you start with the docs.如果您还没有实现它,我建议您从文档开始。

One day he decides to install it again, let's say in another device to make it harder.有一天他决定重新安装它,让我们说在另一台设备上让它变得更难。 He had various information in his profile or maybe an active payment plan he forgot to delete and he wants to do it now.他的个人资料中有各种信息,或者可能是他忘记删除的有效付款计划,他现在想这样做。 He clicks on google log in since it was how he did it, but now the profile information is gone because another account was created with another generated ID.他点击 google 登录,因为他是这样做的,但现在个人资料信息消失了,因为另一个帐户是使用另一个生成的 ID 创建的。

This is only happening if you are using a type of ID other than the one explained above.仅当您使用的 ID 类型不同于上述 ID 时,才会发生这种情况。 If you had used the ID that comes from the authentication process, the second time the user tries to sing-in, even if using a different device, he'll be recognized as the same user with the same data.如果您使用了来自身份验证过程的 ID,则用户第二次尝试唱歌时,即使使用不同的设备,他也会被识别为具有相同数据的同一用户。 In this way, the user will be able to access the same document with the same data and recreate the local cache.这样,用户将能够访问具有相同数据的相同文档并重新创建本地缓存。

Im not sure in which framework you are working in to create the app, but firebase sdk has sign in along with create user with email & password.我不确定您在哪个框架中创建应用程序,但 firebase sdk 已登录并使用 email 和密码创建用户。 Needed data could be saved to user's document on Firestore.需要的数据可以保存到 Firestore 上的用户文档中。

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

相关问题 如何知道用户何时删除了通知 - How to know when user has deleted a notification 如何检查用户是否使用 Google 帐户登录 - How to check if a user has logged in with Google Account 用户停用帐户后如何关闭应用程序? - how to close the app after user deactivate the account? 如何向Android应用发送有关用户已手动更改音量控制键的通知? - How to send a notification to an Android App that the User has manually changed the Volume Control Keys? 如何将付费应用用户帐户链接到系统? - How to link paid app user account to the system? 使用iCloud身份验证方法验证用户是否在我的应用程序中拥有帐户 - Verify if user has account in my app with iCloud auth approach 检测用户是否在应用程序上从唯一设备创建了帐户 - Detecting whether or not user has created an account from a unique device on an app 如何获取Android手机用户的Google帐户名? - How to get android phone user's google account name? 如何从App ID恢复Fabric帐户 - How to recover Fabric Account from App ID 如何找到用户用来登录我的基于google-fit的Android应用程序的帐户(电子邮件)? - How to find which account (email) has user used to log into my google-fit based android app?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM