Skip to content

User bundle - This bundle provides a basic user entity and user repository.

License

Notifications You must be signed in to change notification settings

schvoy/user-bundle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

User bundle

This bundle provides a basic user entity and user repository, that can be used immediately without too much effort, just a few small steps needed to use it.

However, these are extendable and you can add additional properties easily.

Installation

composer require schvoy/user-bundle

Usage

Make your own UserRepository

<?php

declare(strict_types=1);

namespace App\Repository;

use App\Entity\User;
use Doctrine\Persistence\ManagerRegistry;
use Schvoy\UserBundle\Repository\UserRepository as BaseUserRepository;

class UserRepository extends BaseUserRepository
{
    public function __construct(ManagerRegistry $registry)
    {
        parent::__construct($registry, User::class);
    }
}

Make your own User entity

<?php

namespace App\Entity;

use App\Repository\UserRepository;
use Doctrine\ORM\Mapping as ORM;
use Schvoy\UserBundle\Entity\User as BaseUser;

#[ORM\Entity(repositoryClass: UserRepository::class)]
#[ORM\Table(name: 'users')]
class User extends BaseUser
{
   
}

security.yaml

security:
    password_hashers:
        App\Entity\User:
            algorithm: argon2i

    providers:
        app_user_provider:
            entity:
                class: App\Entity\User
                property: email
    [...]

doctrine.yaml

doctrine:
    orm:
        resolve_target_entities:
            Symfony\Component\Security\Core\User\UserInterface: <your-fqcdn-for-your-user-entity-class>
    [...]

Event subscriber

The Schvoy\UserBundle\EventSubscriber\PasswordHashingDoctrineEventSubscriber automatically hashes the plain password, during a new user entity creation or an update (if the password changed).

In some cases, you don't need this behavior, so you can disable it with the following code:

    PasswordHashingDoctrineEventSubscriber::setEnabled(false);

And after that you can re-enable it:

    PasswordHashingDoctrineEventSubscriber::setEnabled(true);

Configuration reference

Extra configuration is not allowed yet for this bundle.

About

User bundle - This bundle provides a basic user entity and user repository.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages