Skip to content

Conversation

@zigzagdev
Copy link
Owner

@zigzagdev zigzagdev commented Jun 29, 2025

Description

This pull request introduces the implementation of the PasswordResetTokenValidatorService, responsible for validating a password reset token by verifying:

  • That both the user_id and token are present and non-empty
  • That a matching record exists in the password_reset_requests table
  • That the token was issued within the last 60 minutes (requested_at threshold)

The logic conforms to domain expectations by:

  • Throwing InvalidArgumentException for missing or invalid input
  • Encapsulating the DB validation logic within a private helper method isValidToken

The implementation adheres to the PasswordResetTokenValidatorInterface and is placed under the Infrastructure layer to isolate external dependencies (e.g., DB access).

@zigzagdev zigzagdev requested a review from Copilot June 29, 2025 08:35
@zigzagdev zigzagdev self-assigned this Jun 29, 2025
@zigzagdev zigzagdev added enhancement New feature or request backend test labels Jun 29, 2025
@zigzagdev zigzagdev linked an issue Jun 29, 2025 that may be closed by this pull request
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Implements a service and interface for validating password reset tokens and adds a basic positive-path test.

  • Introduces PasswordResetTokenValidatorService to enforce non-empty inputs and check token existence within a time window.
  • Defines PasswordResetTokenValidatorInterface in the domain layer.
  • Adds a positive-path integration test for a valid token.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/app/User/Infrastructure/Service/PasswordResetTokenValidatorService.php Implements the token validation logic against the database
src/app/User/Domain/Service/PasswordResetTokenValidatorInterface.php Declares the validation interface
src/app/User/Infrastructure/InfrastructureTest/Service/PasswordResetTokenValidatorServiceTest.php Adds a test for a valid reset token
Comments suppressed due to low confidence (2)

src/app/User/Infrastructure/Service/PasswordResetTokenValidatorService.php:1

  • [nitpick] Consider adding a class-level docblock and method docblocks to explain the service’s responsibility and its public API for better maintainability.
<?php

src/app/User/Infrastructure/InfrastructureTest/Service/PasswordResetTokenValidatorServiceTest.php:66

  • Add negative-path tests for empty inputs, non-existent tokens, and expired tokens to ensure all exception-throwing branches are covered.
    public function test_check_token_validate(): void

@zigzagdev zigzagdev merged commit 23d3c27 into feature/user-password-reset-infra Jun 29, 2025
@zigzagdev zigzagdev deleted the feature/user-password-reset-infra-service branch June 29, 2025 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend enhancement New feature or request test

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Password Reset Infra Token Validator

2 participants