是否可以限制用户登录 Firebase 应用的设备数量?

Cam*_*nes 5 cordova firebase vue.js firebase-authentication

背景:我正在帮助使用 Vue 更新 Cordova 应用程序,以从基于订阅的收入(用户必须付费才能访问该应用程序)转变为基于广告的收入(用户可以免费注册,但当他们使用应用程序时,应用程序中会显示广告。我们想要做的一部分是限制用户可以拥有帐户的设备数量,以避免有人决定与一千个朋友共享他们的付费帐户。我希望效仿 Netflix 对他们帐户的做法。

Netflix 帐户过多屏幕

这是我想到的使用电子邮件/密码身份验证的工作流程(https://firebase.google.com/docs/reference/js/firebase.auth.Auth#signinwithemailandpassword

// I would like to have device information at this point in the application
firebase.auth().signInWithEmailAndPassword(email, password)
    .then(function(result) {
        // Use Realtime Database to associate the device with the user
    })
    .catch(function(error) {
        // I'd like to catch the "too-many-devices" error here, but if needed, I can use the success handler to check device limits
    })
Run Code Online (Sandbox Code Playgroud)

不幸的是,文档中列出的错误代码没有提到“设备太多”之类的错误,这意味着 Firebase 身份验证很可能没有我正在寻找的内置功能。

根据此支持文档(https://support.google.com/firebase/answer/6318039?hl=en),听起来 Firebase Analytics 已经有某种方法来识别设备。如果可能的话我想访问它。我所做的其他搜索似乎总是向我指出身份验证限制(https://firebase.google.com/docs/auth/limits),其中没有提及任何有关独特设备的信息。

是否可以限制用户登录 Firebase 应用的设备数量?

Dou*_*son 2

Firebase Auth 不提供任何机制来跟踪或限制用户使用的设备数量。事实上,它真正所做的只是公开可以从互联网上任何地方使用的公共 API。它根本不具有“设备”的意义。

如果您想限制用户可以使用的设备数量,则必须以某种方式自行实现。由于 Firebase 基本上允许从任何来源无限制地登录,因此您无法严格执行这一点。有人将能够找到一种方法来解决您所实施的任何问题。但是您当然可以在您的应用程序中执行大量检查,以确保不同的设备被跟踪和限制,并假设最终用户不会尝试绕过您的限制。