-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Vincent <[email protected]>
- Loading branch information
1 parent
ad2d782
commit 29c24cc
Showing
11 changed files
with
98 additions
and
103 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 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 |
---|---|---|
|
@@ -16,31 +16,22 @@ | |
use CoopTilleuls\ForgotPasswordBundle\Entity\AbstractPasswordToken; | ||
use Doctrine\ORM\Mapping as ORM; | ||
|
||
/** | ||
* @ORM\Entity | ||
* | ||
* @author Vincent CHALAMON <[email protected]> | ||
*/ | ||
#[ORM\Entity] | ||
final class PasswordToken extends AbstractPasswordToken | ||
{ | ||
/** | ||
* @var int | ||
* | ||
* @ORM\Id | ||
* | ||
* @ORM\Column(type="integer") | ||
* | ||
* @ORM\GeneratedValue(strategy="AUTO") | ||
*/ | ||
#[ORM\Id] | ||
#[ORM\Column(type: 'integer')] | ||
#[ORM\GeneratedValue(strategy: 'AUTO')] | ||
private $id; | ||
|
||
/** | ||
* @var User | ||
* | ||
* @ORM\ManyToOne(targetEntity="User") | ||
* | ||
* @ORM\JoinColumn(nullable=false, name="user_id") | ||
*/ | ||
#[ORM\ManyToOne(targetEntity: 'User')] | ||
#[ORM\JoinColumn(nullable: false, name: 'user_id')] | ||
private $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 |
---|---|---|
|
@@ -16,43 +16,33 @@ | |
use Doctrine\ORM\Mapping as ORM; | ||
use Symfony\Component\Security\Core\User\UserInterface; | ||
|
||
/** | ||
* @ORM\Entity | ||
* | ||
* @author Vincent CHALAMON <[email protected]> | ||
*/ | ||
#[ORM\Entity] | ||
final class User implements UserInterface | ||
{ | ||
/** | ||
* @var int | ||
* | ||
* @ORM\Id | ||
* | ||
* @ORM\Column(type="integer") | ||
* | ||
* @ORM\GeneratedValue(strategy="AUTO") | ||
*/ | ||
#[ORM\Id] | ||
#[ORM\Column(type: 'integer')] | ||
#[ORM\GeneratedValue(strategy: 'AUTO')] | ||
private $id; | ||
|
||
/** | ||
* @var string | ||
* | ||
* @ORM\Column(type="string") | ||
*/ | ||
#[ORM\Column(type: 'string')] | ||
private $email; | ||
|
||
/** | ||
* @var string | ||
* | ||
* @ORM\Column(type="string") | ||
*/ | ||
#[ORM\Column(type: 'string')] | ||
private $username; | ||
|
||
/** | ||
* @var string | ||
* | ||
* @ORM\Column(type="string") | ||
*/ | ||
#[ORM\Column(type: 'string')] | ||
private $password; | ||
|
||
/** | ||
|
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 |
---|---|---|
|
@@ -84,7 +84,7 @@ public function resetDatabase(): void | |
$purger->setPurgeMode(ORMPurger::PURGE_MODE_TRUNCATE); | ||
try { | ||
$purger->purge(); | ||
} catch (\Exception $e) { | ||
} catch (Exception $e) { | ||
$schemaTool = new SchemaTool($this->doctrine->getManager()); | ||
$schemaTool->createSchema($this->doctrine->getManager()->getMetadataFactory()->getAllMetadata()); | ||
} | ||
|
@@ -95,15 +95,15 @@ public function resetDatabase(): void | |
*/ | ||
public function iHaveAValidToken(): void | ||
{ | ||
$this->passwordTokenManager->createPasswordToken($this->createUser(), new \DateTime('+1 day')); | ||
$this->passwordTokenManager->createPasswordToken($this->createUser(), new DateTime('+1 day')); | ||
} | ||
|
||
/** | ||
* @Given I have an expired token | ||
*/ | ||
public function iHaveAnExpiredToken(): void | ||
{ | ||
$this->passwordTokenManager->createPasswordToken($this->createUser(), new \DateTime('-1 minute')); | ||
$this->passwordTokenManager->createPasswordToken($this->createUser(), new DateTime('-1 minute')); | ||
} | ||
|
||
/** | ||
|
@@ -151,7 +151,7 @@ public function iShouldReceiveAnEmail($value = '[email protected]'): void | |
$messages = $mailCollector->getEvents()->getMessages(); | ||
Assert::assertCount(1, $messages, 'No email has been sent'); | ||
|
||
/** @var \Symfony\Component\Mime\Email $message */ | ||
/** @var Symfony\Component\Mime\Email $message */ | ||
$message = $messages[0]; | ||
Assert::assertInstanceOf(RawMessage::class, $message); | ||
Assert::assertEquals('Réinitialisation de votre mot de passe', $message->getSubject()); | ||
|
@@ -237,7 +237,7 @@ public function iResetMyPasswordUsingNoParameter(): void | |
*/ | ||
public function iUpdateMyPassword(): void | ||
{ | ||
$token = $this->passwordTokenManager->createPasswordToken($this->createUser(), new \DateTime('+1 day')); | ||
$token = $this->passwordTokenManager->createPasswordToken($this->createUser(), new DateTime('+1 day')); | ||
|
||
$this->client->request( | ||
'POST', | ||
|
@@ -270,7 +270,7 @@ public function thePasswordShouldHaveBeenUpdated(): void | |
*/ | ||
public function iUpdateMyPasswordUsingNoPassword(): void | ||
{ | ||
$token = $this->passwordTokenManager->createPasswordToken($this->createUser(), new \DateTime('+1 day')); | ||
$token = $this->passwordTokenManager->createPasswordToken($this->createUser(), new DateTime('+1 day')); | ||
|
||
$this->client->request('POST', sprintf('/api/forgot-password/%s', $token->getToken())); | ||
} | ||
|
@@ -299,7 +299,7 @@ public function iUpdateMyPasswordUsingAnInvalidToken(): void | |
*/ | ||
public function iUpdateMyPasswordUsingWrongProvider(): void | ||
{ | ||
$token = $this->passwordTokenManager->createPasswordToken($this->createAdmin(), new \DateTime('+1 day'), $this->providerChain->get('admin')); | ||
$token = $this->passwordTokenManager->createPasswordToken($this->createAdmin(), new DateTime('+1 day'), $this->providerChain->get('admin')); | ||
|
||
$this->client->request( | ||
'POST', | ||
|
@@ -320,7 +320,7 @@ public function iUpdateMyPasswordUsingWrongProvider(): void | |
*/ | ||
public function iUpdateMyPasswordUsingAValidProviderButAnInvalidPasswordField(): void | ||
{ | ||
$token = $this->passwordTokenManager->createPasswordToken($this->createAdmin(), new \DateTime('+1 day'), $this->providerChain->get('admin')); | ||
$token = $this->passwordTokenManager->createPasswordToken($this->createAdmin(), new DateTime('+1 day'), $this->providerChain->get('admin')); | ||
|
||
$this->client->request( | ||
'POST', | ||
|
@@ -341,7 +341,7 @@ public function iUpdateMyPasswordUsingAValidProviderButAnInvalidPasswordField(): | |
*/ | ||
public function iUpdateMyPasswordUsingAnExpiredToken(): void | ||
{ | ||
$token = $this->passwordTokenManager->createPasswordToken($this->createUser(), new \DateTime('-1 minute')); | ||
$token = $this->passwordTokenManager->createPasswordToken($this->createUser(), new DateTime('-1 minute')); | ||
|
||
$this->client->request( | ||
'POST', | ||
|
@@ -362,7 +362,7 @@ public function iUpdateMyPasswordUsingAnExpiredToken(): void | |
*/ | ||
public function iGetAPasswordToken(): void | ||
{ | ||
$token = $this->passwordTokenManager->createPasswordToken($this->createUser(), new \DateTime('+1 day')); | ||
$token = $this->passwordTokenManager->createPasswordToken($this->createUser(), new DateTime('+1 day')); | ||
$token->setToken('d7xtQlJVyN61TzWtrY6xy37zOxB66BqMSDXEbXBbo2Mw4Jjt9C'); | ||
$this->doctrine->getManager()->persist($token); | ||
$this->doctrine->getManager()->flush(); | ||
|
@@ -387,7 +387,7 @@ public function iShouldGetAPasswordToken(): void | |
*/ | ||
public function iGetAPasswordTokenUsingAnExpiredToken(): void | ||
{ | ||
$token = $this->passwordTokenManager->createPasswordToken($this->createUser(), new \DateTime('-1 minute')); | ||
$token = $this->passwordTokenManager->createPasswordToken($this->createUser(), new DateTime('-1 minute')); | ||
|
||
$this->client->request('GET', sprintf('/api/forgot-password/%s', $token->getToken())); | ||
} | ||
|
Oops, something went wrong.