Enforce email verification for password-based login + add resend verification endpoint#34
Draft
Enforce email verification for password-based login + add resend verification endpoint#34
Conversation
Co-authored-by: star8ks <1812388+star8ks@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] feat: require verified email for password login & add resend endpoint
Enforce email verification for password-based login + add resend verification endpoint
Aug 30, 2025
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements security enhancement to require email verification for password-based authentication while preserving social login functionality. Addresses security review item PR-2 by preventing unverified email addresses from obtaining API tokens via
/api/v1/user/login.Problem
Currently, users implementing
MustVerifyEmailcan still obtain API tokens via/api/v1/user/logineven ifemail_verified_atis null. This weakens account integrity as unverified email addresses can be used immediately for API access.Solution
1. Email Verification Enforcement
Modified
LoginController::login()to check email verification status after successful credential authentication but before token issuance:Key Design Decisions:
$user->password !== ''to exclude social accounts with empty passwordserror: 'email_not_verified'identifier for client handling2. Resend Verification Endpoint
Added authenticated endpoint
POST /api/v1/user/email/resend:3. Response Helper Method
Added
responseError()method to base Controller for consistent error responses:Testing
Comprehensive test coverage includes:
already_verified)verification_link_sent)Backward Compatibility
Dependencies
Leverages existing Laravel infrastructure:
MustVerifyEmailinterfaceEventServiceProvideralready configured withSendEmailVerificationNotificationlistenerhasVerifiedEmail()andsendEmailVerificationNotification()methodsDocumentation
Added
docs/email-verification.mdexplaining the new behavior and API responses.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
mirrors.huaweicloud.com/usr/bin/php8.3 -n -c /tmp/0trjY8 /usr/bin/composer install --no-dev --optimize-autoloader(dns block)If you need me to access, download, or install something from one of these locations, you can either:
This pull request was created as a result of the following prompt from Copilot chat.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.