To store a code in Bubble’s database that expires in 1 hour, you can set up a simple and secure system using a custom data type. Start by creating a new data type called Token in the Data tab. Add the following fields: code (text), expires_at (date), user (User), and is_used(yes/no). This structure lets you track the token, link it to a user, set an expiration time, and flag whether it’s been used.
Next, create a backend workflow to generate the token. This workflow should accept a User parameter. Inside the workflow, use Bubble’s “Generate random string” action to create a secure code. Then, create a new Token entry with the generated code, set expires_at to “Current date/time + 55 minutes”, and link the user if needed.
To validate tokens later, use a search or workflow action that checks:
- The token exists,
- It has not expired (Current date/time < expires_at),
- It hasn’t been used yet (is_used = no).