-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow for a custom implementation of the token generator
ResetPasswordTokenComponents is internal, consumers now can create their own implementation of the ResetPasswordTokenGenerator without having to use our internal token components class.
- Loading branch information
Showing
4 changed files
with
36 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
|
||
use SymfonyCasts\Bundle\ResetPassword\Exception\ResetPasswordRuntimeException; | ||
use SymfonyCasts\Bundle\ResetPassword\Model\ResetPasswordTokenComponents; | ||
use SymfonyCasts\Bundle\ResetPassword\Model\ResetPasswordTokenComponentsInterface; | ||
|
||
/** | ||
* @author Jesse Rushlow <[email protected]> | ||
|
@@ -38,7 +39,7 @@ public function __construct( | |
* | ||
* @throws ResetPasswordRuntimeException | ||
*/ | ||
public function createToken(\DateTimeInterface $expiresAt, int|string $userId, ?string $verifier = null): ResetPasswordTokenComponents | ||
public function createToken(\DateTimeInterface $expiresAt, int|string $userId, ?string $verifier = null): ResetPasswordTokenComponentsInterface | ||
{ | ||
if (null === $verifier) { | ||
$verifier = $this->generator->getRandomAlphaNumStr(); | ||
|
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 |
---|---|---|
|
@@ -9,12 +9,12 @@ | |
|
||
namespace SymfonyCasts\Bundle\ResetPassword\Generator; | ||
|
||
use SymfonyCasts\Bundle\ResetPassword\Model\ResetPasswordTokenComponents; | ||
use SymfonyCasts\Bundle\ResetPassword\Model\ResetPasswordTokenComponentsInterface; | ||
|
||
/** | ||
* @author Jesse Rushlow <[email protected]> | ||
*/ | ||
interface ResetPasswordTokenGeneratorInterface | ||
{ | ||
public function createToken(\DateTimeInterface $expiresAt, int|string $userId, ?string $verifier = null): ResetPasswordTokenComponents; | ||
public function createToken(\DateTimeInterface $expiresAt, int|string $userId, ?string $verifier = null): ResetPasswordTokenComponentsInterface; | ||
} |
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,31 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the SymfonyCasts ResetPasswordBundle package. | ||
* Copyright (c) SymfonyCasts <https://symfonycasts.com/> | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace SymfonyCasts\Bundle\ResetPassword\Model; | ||
|
||
/** | ||
* @author Jesse Rushlow <[email protected]> | ||
*/ | ||
interface ResetPasswordTokenComponentsInterface | ||
{ | ||
/** | ||
* @return string Non-hashed random string used to fetch request objects from persistence | ||
*/ | ||
public function getSelector(): string; | ||
|
||
/** | ||
* @return string The hashed non-public token used to validate reset password requests | ||
*/ | ||
public function getHashedToken(): string; | ||
|
||
/** | ||
* The public token consists of a concatenated random non-hashed selector string and random non-hashed verifier string. | ||
*/ | ||
public function getPublicToken(): string; | ||
} |