[PR #7397] [MERGED] refactor: replace nested conditionals with switch in email verification #7282

Closed
opened 2026-03-13 13:30:40 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7397
Author: @bytaesu
Created: 1/15/2026
Status: Merged
Merged: 1/15/2026
Merged by: @himself65

Base: canaryHead: cursor/pr-7252-code-refactor-b92a


📝 Commits (1)

  • 504a088 refactor: replace nested conditionals with switch in email verification

📊 Changes

1 file changed (+150 additions, -137 deletions)

View changed files

📝 packages/better-auth/src/api/routes/email-verification.ts (+150 -137)

📄 Description

Refactored the email verification handler to use a switch statement on requestType for better clarity, separating change-email-confirmation, change-email-verification, and legacy flow cases. This improves readability without changing behavior.


Summary by cubic

Replaced nested conditionals in the email verification handler with a switch on requestType to make each flow clearer. Improves readability without changing behavior or API responses.

  • Refactors
    • Added switch(requestType) with cases for change-email-confirmation, change-email-verification, and legacy flow.
    • Consolidated session creation, cookie updates, and redirects inside each case to reduce duplication.
    • Preserved existing callbacks and response shapes.

Written for commit 504a088ee2. Summary will update on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/7397 **Author:** [@bytaesu](https://github.com/bytaesu) **Created:** 1/15/2026 **Status:** ✅ Merged **Merged:** 1/15/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `cursor/pr-7252-code-refactor-b92a` --- ### 📝 Commits (1) - [`504a088`](https://github.com/better-auth/better-auth/commit/504a088ee2595ed95415e9ae366daf7e4d2d4ec3) refactor: replace nested conditionals with switch in email verification ### 📊 Changes **1 file changed** (+150 additions, -137 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/routes/email-verification.ts` (+150 -137) </details> ### 📄 Description Refactored the email verification handler to use a switch statement on requestType for better clarity, separating change-email-confirmation, change-email-verification, and legacy flow cases. This improves readability without changing behavior. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Replaced nested conditionals in the email verification handler with a switch on requestType to make each flow clearer. Improves readability without changing behavior or API responses. - **Refactors** - Added switch(requestType) with cases for change-email-confirmation, change-email-verification, and legacy flow. - Consolidated session creation, cookie updates, and redirects inside each case to reduce duplication. - Preserved existing callbacks and response shapes. <sup>Written for commit 504a088ee2595ed95415e9ae366daf7e4d2d4ec3. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-13 13:30:40 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#7282