How can we restrict a users access based on them doing X number of things

E.g. we are calling an API, to enrich data - and we want to restrict how much free use a user can have - e.g. if they receive 20 enrichments, restrict them from doing any more that day?

Each time of API call, store the number of times that particular used this service. Once they reach max value then just terminate the api.
NOTE: Each of start day you must reset the value.

@matthew2 The way I would do it would be to create another object in your database called MetaData or whatever you like. You wouldn’t even have to put any additional fields on it since the built in fields have both a date and a user already though adding more fields would give more depth to your data.

Every time a user receives an enrichment, add a step to the workflow to create a new MetaData record and that will make the current user the creator of that record.

For your constraints then you can simply do a search for MetaData where the created date is greater than current date/time: change hours to 0 change minutes to 0 change seconds to 0 and the creator is the current user and use the :count operator.

If the count of those records is 20 or more they are cut off. If it’s less than 20 they can get another enrichment.

This would also let you pull full history on every user such as how many Enrichments they received on any given day.

1 Like

:point_up: Now this is a correct answer, @eli.

Btw, field-less objects like you describe are useful for many other things. For example, you can create an Administrator object and use it to create a very secure superuser privacy role (in combination with privacy rules, as ive described elsewhere).

1 Like

Thank you all so much, really appreciate the answers and guidance! This looks great.

We are thinking of doing this as a bit of a marketing play, to give users exposure to our enrichment data - before committing to sign up.

Do you think it’s possible with Bubble to do the same as suggested with a session cookie, instead of requiring a user to login? Either way, I’ll use this for logged in user restrictions - but would love to know if I can achieve this without.

You can do that without even managing cookies yourself (Bubble will deal with it). However, I’d make the user create an account. (What good is letting bots or crafty users use your thing?)

Point being that you can’t do anything to convert an unidentified user, really.

Keep it simple (just require them to signup/login).

This topic was automatically closed after 70 days. New replies are no longer allowed.