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?