是否可以限制用户可以登录 Firebase 应用的设备数量? [英] Is it possible to limit the number of devices a user can log in to a Firebase app with?

查看:36
本文介绍了是否可以限制用户可以登录 Firebase 应用的设备数量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Netflix 帐户过多屏幕

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

//我想在应用程序中拥有此时的设备信息firebase.auth().signInWithEmailAndPassword(email, password).then(函数(结果){//使用实时数据库将设备与用户关联}).catch(函数(错误){//我想捕捉太多设备"这里有错误,但如果需要,我可以使用成功处理程序来检查设备限制})

不幸的是,文档中列出的错误代码没有提到设备太多".某种错误,这意味着 Firebase 身份验证很可能没有我正在寻找的内置功能.<​​/p>

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

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

解决方案

Firebase Auth 不提供任何机制来跟踪或限制用户使用的设备数量.事实上,它真正做的就是公开可以从互联网上的任何地方使用的公共 API.它没有设备"的感觉.完全没有.

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

Context: I'm helping update a Cordova app using Vue to move from a subscription-based revenue, where the user has to pay in order to access the app, to an ad-based revenue, where the user can sign up for free but will have ads displayed in the app as they're using it. Part of what we want to do is limit the number of devices that a user can have an account on to avoid someone deciding to share their paid account with a thousand of their friends. I'm looking to emulate what Netflix does with their accounts.

Netflix too many accounts screen

This is the workflow I had in mind using the email/password authentication (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
    })

Unfortunately, the error codes listed in the documentation don't mention a "too-many-devices" sort of error, which means that Firebase Authentication most likely doesn't have the functionality I'm looking for built into it.

According to this support documentation (https://support.google.com/firebase/answer/6318039?hl=en), it sounds like Firebase Analytics has some way to identify the device already. I would like to access that if possible. Other searches I've done always seem to point me to auth limits (https://firebase.google.com/docs/auth/limits), which doesn't mention anything about unique devices.

Is it possible to limit the number of devices a user can log in to a Firebase app with?

解决方案

Firebase Auth does not provide any mechanism to track or limit how many devices the user is using. In fact all it really does is expose public APIs that can be used from anywhere on the internet. It does not hold a sense of "device" at all.

If you want to limit the number of devices that a user can use, that's something you'll have to somehow implement that yourself. Since Firebase allows essentially unlimited sign-ins from any source, you won't be able to enforce this strictly. Someone will be able to find a way to work around whatever you implement. But you can certainly perform a lot of checks in your app to make sure that distinct devices are being tracked and limited, and assume that end users will not try to work around your limitations.

这篇关于是否可以限制用户可以登录 Firebase 应用的设备数量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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