Description
Simple bundle that helps you to implement some steps of a very basic auth system (Symfony Guard Authenticator) like:
- Register
- Confirm Account
- Reset Password
Look at demo
folder for examples.
Installation
1 Add the bundle to your vendor
...
Note: still in beta so load from the repository
Add this config below in your composer.json
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/Damian972/auth-bundle"
}
],
"require-dev": {
"damian972/auth-bundle": "dev-master"
}
}
then run:
composer update
2 Register the bundle in config/bundles.php
$bundles = [
...
Damian972\AuthBundle\AuthBundle::class => ['all' => true],
];
3 Set doctrine config
doctrine:
orm:
resolve_target_entities:
Damian972\AuthBundle\Contracts\UserInterface: <your_user_entity>
4 Implement UserInterface
to your user entity
...
use Damian972\AuthBundle\Contracts\UserInterface;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=UserRepository::class)
* @ORM\HasLifecycleCallbacks()
* @ORM\Table(name="users")
*/
class User implements UserInterface
{
...
}
5 Set the bundle config (config/packages/auth.yaml)
auth:
max_login_attempts: 3
token_expire_after: 30 #in minutes
Events
Events to dispatch manually (see demo folder):
Damian972\AuthBundle\Event\AccountConfirmedEvent
Damian972\AuthBundle\Event\BadCredentialsEvent
Damian972\AuthBundle\Event\RegisteredUserEvent
Automatically dispatched:
Damian972\AuthBundle\Event\PasswordRecoveredEvent
Damian972\AuthBundle\Event\PasswordResetRequestEvent