-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into page-actors
- Loading branch information
Showing
12 changed files
with
71 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,15 +5,18 @@ App\Entity\User: | |
email: [email protected] | ||
plainPassword: Test1234 | ||
roles: [ 'ROLE_ADMIN' ] | ||
isValidated: true | ||
user_2: | ||
firstName: John | ||
lastName: Editor Doe | ||
email: [email protected] | ||
plainPassword: Test1234 | ||
roles: [ 'ROLE_EDITOR_ACTORS', 'ROLE_EDITOR_PROJECTS', "ROLE_EDITOR_RESOURCES", "ROLE_EDITOR_DATA" ] | ||
isValidated: true | ||
user_3: | ||
firstName: Jane | ||
lastName: Doe | ||
email: [email protected] | ||
plainPassword: Test1234 | ||
roles: [ 'ROLE_USER' ] | ||
roles: [ 'ROLE_USER' ] | ||
isValidated: true |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace App\Event\EventListener; | ||
|
||
use App\Entity\User; | ||
use App\Security\PasswordHasher; | ||
use Doctrine\Bundle\DoctrineBundle\Attribute\AsEntityListener; | ||
use Doctrine\ORM\Events; | ||
use Doctrine\Persistence\Event\LifecycleEventArgs; | ||
|
||
#[AsEntityListener(event: Events::prePersist, method: 'hashPassword', entity: User::class)] | ||
#[AsEntityListener(event: Events::preUpdate, method: 'hashPassword', entity: User::class)] | ||
class UserListener | ||
{ | ||
private PasswordHasher $passwordHasher; | ||
|
||
public function __construct(PasswordHasher $passwordHasher) | ||
{ | ||
$this->passwordHasher = $passwordHasher; | ||
} | ||
|
||
public function hashPassword(User $user, LifecycleEventArgs $event): void | ||
{ | ||
$this->passwordHasher->hashPassword($user); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace App\Security; | ||
|
||
use App\Entity\User; | ||
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface; | ||
|
||
class PasswordHasher | ||
{ | ||
private UserPasswordHasherInterface $passwordHasher; | ||
|
||
public function __construct(UserPasswordHasherInterface $passwordHasher) | ||
{ | ||
$this->passwordHasher = $passwordHasher; | ||
} | ||
|
||
public function hashPassword(User $user): void | ||
{ | ||
if ($user->getPlainPassword()) { | ||
$user->setPassword( | ||
$this->passwordHasher->hashPassword( | ||
$user, | ||
$user->getPlainPassword() | ||
) | ||
); | ||
|
||
$user->eraseCredentials(); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.