I would like to set up a licensing scheme for a Xojo desktop app using Postgres where users pay for access based on the number of simultaneous users (such as single user, 2-5 users, 6-10 users).
I have found that if I set Postgres to one user, if my desktop app crashes it is difficult for the user to log back in because Postgres does not release the user for minutes (or longer).
In addition, my app logs into the database, grabs data, and then releases the database - so it is not logged in for more than a few seconds at a time.
I am wondering what others using Postgres are doing.
create a table “usercounts”
each time a user logs in, create a record in that table with his mac address or UUID
each time he logs out, delete that record
count the nb of records at login, if it exeeds the number allowed refuse the login.
if the user force quit the app, its UUID will still be in the table.
at next login, see the UUID is already in the table, allow the user to login without creating the record.
this should forbid any filling of the table if there are too many unexpecting quit.
What you are describing sounds a lot like a “named user” licensing scheme. Here, the user must log-in (authenticate him/herself to the application/database. You manage the users that can be logged in, and actually are logged in. There are variations on this theme.