Download the PHP package danielburger1337/2fa-email without Composer
On this page you can find all versions of the php package danielburger1337/2fa-email. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download danielburger1337/2fa-email
More information about danielburger1337/2fa-email
Files in danielburger1337/2fa-email
Package 2fa-email
Short Description Extends scheb/2fa-bundle with two-factor authentication via email
License MIT
Homepage https://github.com/danielburger1337/scheb-2fa-email
Informations about the package 2fa-email
danielburger1337/2fa-email
This bundle is an extension of scheb/2fa-bundle that provides a more advanced email two-factor provider than the default scheb/2fa-email provider.
It adds the ability to let an authentication code expire (by default 15 minutes) and makes the customization of the generated email message a bit more developer friendly.
Installation
Customize the email
There are multiple ways you can customize the creation and sending of the authentication code message.
By default, the bundle generates a bare bones email.
You can customize the subject and text body by setting the email_subject
, email_body
, sender_email
and sender_name
parameters.
The "{{AUTH_CODE}}" string in the email_body
template will be replaced with the actual auth code when the email is sent.
You can change the symfony/mime email message generation (e.g. create a twig TemplatedEmail) by creating a service that implements the
AuthCodeEmailGeneratorInterface and setting the email_generator
parameter
to that service id.
The generated message is then sent via symfony/mailer and the mailer.mailer
service by default. If you want to use
a different symfony/mailer service to send the messages, simply set the service id to the symfony_mailer
parameter.
Lastly, if you dont want to use symfony/mailer at all, you can create a service that implements AuthCodeMailerInterface that handles the message generation and sending completly on its own. To use this service,
all you have to do is set the mailer
parameter to that services id.
Resend an authentication code
If you want to resend the authentication message (maybe the message got lost in transit),
the easiest way is to use a RequestEvent::class
event listener and inject te
AuthCodeMailerInterface service and call the "sendAuthCode" method.
Using a "normal" route doesn't work by default because scheb/2fa-bundle will always redirect that route to the 2fa endpoint.
Configuration Reference
The listed values are the default values. Every value is optional.
License
This software is available under the MIT license.
All versions of 2fa-email with dependencies
scheb/2fa-bundle Version ^6.4 || ^7.0
symfony/framework-bundle Version ^6.4 || ^7.0
symfony/clock Version ^6.4 || ^7.0