Skip to content

Conversation

@yinx
Copy link
Contributor

@yinx yinx commented May 5, 2022

Fixes #22 #21

@yinx yinx self-assigned this May 5, 2022
Comment on lines 8 to 12
class CleanupVerificationCodesCommand extends Command
{
protected $signature = 'verification-code:cleanup {days : Codes older than these days will be deleted.}';

protected $description = 'Remove verification code older than the given days.';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
class CleanupVerificationCodesCommand extends Command
{
protected $signature = 'verification-code:cleanup {days : Codes older than these days will be deleted.}';
protected $description = 'Remove verification code older than the given days.';
class PruneCommand extends Command
{
protected $signature = 'verification-code:prune {--hours=24 : The number of hours to retain verification codes}';
protected $description = 'Prune old verification codes';

I would set it up similarly to the prune command of Telescope (https://github.com/laravel/telescope/blob/4.x/src/Console/PruneCommand.php)

* @return bool
*/
public function verify(string $code, string $verifiable)
public function verify(string $code, string $verifiable, bool $cleanup = true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought, maybe we should call it $deleteAfterVerification 🤔 so there can not be any confusion about the meaning.

can you also document this extra option?

Comment on lines 18 to 20
VerificationCode::query()
->where('created_at', '<=', now()->subDays($days))
->delete();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
VerificationCode::query()
->where('created_at', '<=', now()->subDays($days))
->delete();
VerificationCode::where('created_at', '<=', now()->subDays($days))->delete();

can be on one line

@yinx yinx requested a review from gdebrauwer May 5, 2022 12:04
*
* @param string $code
* @param string $verifiable
* @param bool $cleanup
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @param bool $cleanup
* @param bool $deleteAfterVerification


$this->artisan('verification-code:prune', ['--hours' => 3]);

$dbVerificationCode = VerificationCode::all();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$dbVerificationCode = VerificationCode::all();
$dbVerificationCodes = VerificationCode::all();

@yinx yinx merged commit 51562dd into master May 6, 2022
@yinx yinx deleted the feature/allow_verification_without_code_removal branch May 6, 2022 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants