Strategy for Handling an X-day Trial

I’m thinking of implementing a 30-60 day free trial of a premium feature. I’m looking for opinions (or suggested reading) about the best way to handle this in meteor. Note, I’m using blaze with 1.2.

I think the easiest thing to do is (1) mark the date they start the trial in the same schema I keep the T/F boolean to check if they have access to the premium feature. Then wire up a quick helper to check if the date is greater than today’s date + 30 days? Then use an {{#if}} to show/hide a message that they need to pay up?

I’m not sure how permanent this feature will be, so I’m just looking for a quick and dirty way to implement this.

Your idea would work, but is very insecure. One simple tip: trust nothing that happens on the client-side. In other words, it’s probably advisable to put the premium check in a server-side method instead of simply accessing the client-side data and creating a helper.

The first part of putting the trial start date in some collection is fine if the client can’t edit that data (using either allow/deny or using methods to update data and checking that that field has not been changed).

Secondly you could have a cron job running server-side that goes over all the users that have a running trial, if it expired, store some flag that it has expired.

Thirdly you should use a meteor method to check this flag, not just the local data (as that can be tampered with). You could of course still put this in a helper, or have it run on onCreated and stored in some variable, etc.

This would give you a safer (it’s never 100% safe) way to test if the user’ trial has expired or not, without them being able to trick your app into thinking they can still access the feature.

1 Like