Has anyone successfully set up Two Factor Authentication in Wappler based on the supported security tools in Wappler? I'm using PHP.
I just need something simple that will send a timed link to the users email that times out in like 15 minutes. I don't need codes or anything like that.
Hey Brad, I’ve set up a flow like this in Wappler with PHP using only the native security tools. It’s basically just sending the user a secure link that expires after 15 minutes.
Here’s the approach I used:
Login step
User logs in with the Security Provider.
Instead of considering the session active immediately, I generate a unique token and store it in a table along with the user_id, an expiry time (NOW + 15 minutes), and a “used” flag.Example table fields:
id (int, pk, auto_increment)
user_id (int, fk)
token (varchar 64, unique)
expires_at (datetime)
used (tinyint default 0)
Generate and send link
- Token can be generated with something like {{randomid(32)}}.
- Insert it into the database with the expiry timestamp.
- Send the user an email containing a link such as:
https://mysite.com/verify_2fa.php?token={{token}}
Verification page
Create a Server Action that receives the token parameter.
Check the user_tokens table:
If the token exists,
expires_at > NOW(),
and used = 0.
If it’s valid:
Set used = 1.
Activate the session in the Security Provider (e.g., securityProvider.setIdentity(user_id)).
Redirect to the "dashboard".
If it’s not valid:
Show an error like “The link has expired or has already been used.”
Cleanup
Optionally run a scheduled action/cron to delete expired tokens.
This works completely with Wappler’s server actions (DB Insert, Mailer, DB Query, Condition, Security Provider Login). No external libraries required, and the logic is straightforward to put together.
Anytime, Brad! Happy to hear it was what you were looking for. Don't hesitate to give me a shout if you get stuck on any step. Good luck with the build!