To implement a free trial function, each user has a “Trial Status”, “Subscription Status”, and “Active Status”. The default values are 1, 0, and empty respectively.
Upon clicking the login button several actions occur:
- The user is logged in
- Their “Trial Status” is set to 0 if their account is older than 30 days
- Then their “Active Status” is calculated as “Trial Status” + “Subscription Status”
- If their “Active Status” is greater than 0, they are linked to the Home screen
- If their “Active Status” is equal to 0, they are linked to the Manage Subscription screen
- When the user pays for a subscription, their “Subscription Status” is set to 1
In theory, this allows for a 30-day free trial, and if the user doesn’t subscribe, they are prevented from navigating into the app, and are blocked by the Manage Subscription screen. When they pay, they can login normally and go to the Home screen.
The issue I’m having is this…
In the database, I have manually set the default values for my user as:
“Trial Status” = 0
“Subscription Status” = 1
“Active Status” = empty
When I attempt to login, the login screen just refreshes and deletes the email/password entered, and I am not linked to the Home screen or the Manage Subscription screen.
Upon checking the user database, I see that the “Active Status” field is still empty. If I manually enter a 1 in this field in the database, it reverts to empty after a login attempt.
It seems that the “Trial Status” + “Subscription Status” is not being calculated
Am I trying to use too many actions in the login button?
Since the “Trial Status” is conditionally updated just before the calculation, could this database read/write block the calculation from being performed due to read/write speed?
Any other ideas why this might be happening?
Thank you