-
Notifications
You must be signed in to change notification settings - Fork 126
fix: improve Play vs Bot accessibility #148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: improve Play vs Bot accessibility #148
Conversation
📝 WalkthroughWalkthroughSign-up now branches by environment: development/local auto-verifies users, skips verification-code creation, generates a JWT and returns an accessToken with user data; production generates and stores a verification code, sends a verification email, and responds with a success message and user data. Frontend edits are formatting-only. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Server
participant DB
participant EmailService
rect rgb(248,249,250)
note right of Client: POST /signup (email, password, ...)
end
Client->>Server: POST /signup
Server->>DB: create user record (IsVerified per env)
alt Env: development/local
Server->>DB: mark IsVerified = true (no verification code)
Server->>Server: generate JWT
Server-->>Client: 200 { accessToken, user }
else Env: production
Server->>DB: create & store verification code
Server->>EmailService: send verification email (code)
alt Email send success
Server-->>Client: 200 { message: "verification email sent", user }
else Email send failure
Server-->>Client: 500 { error: "email send failed" }
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
🧰 Additional context used🧬 Code graph analysis (1)backend/controllers/auth.go (1)
🔇 Additional comments (5)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
backend/controllers/auth.go (1)
124-211: Frontend signup flow is broken and incompatible with auto-verified users.After signup, the backend now auto-verifies users and returns an
accessTokenimmediately. However, the frontend'sSignUpFormunconditionally callsstartOtpVerification(email)after signup (forms.tsx line 128), redirecting users to theOTPVerificationForm. This form asks users to enter an OTP that was never sent—since the backend skips email verification in development. The user becomes stuck unable to complete signup.The frontend must be updated to either:
- Check if the user is already verified (skip OTP step when auto-verified), or
- Handle the new immediate login response and navigate directly to the dashboard instead of the OTP verification page
🧹 Nitpick comments (1)
backend/controllers/auth.go (1)
158-158: Consider conditional verification code generation.The verification code is generated but never used when auto-verification is enabled. Consider generating it only when email verification will be performed (i.e., in production environments).
💡 Example implementation
- // Generate verification code - verificationCode := utils.GenerateRandomCode(6) + // Generate verification code only if needed + isDevelopment := os.Getenv("ENV") == "development" || os.Getenv("ENV") == "local" + verificationCode := "" + if !isDevelopment { + verificationCode = utils.GenerateRandomCode(6) + }
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
backend/controllers/auth.gofrontend/src/Pages/DebateRoom.tsx
🔇 Additional comments (1)
frontend/src/Pages/DebateRoom.tsx (1)
837-837: LGTM! Accessibility improvement for input text visibility.Adding
text-gray-900andbg-whiteclasses ensures the input text has proper contrast and is clearly visible to users, which aligns with the PR's accessibility improvement objectives.
37469fb to
7aa9543
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
backend/controllers/auth.gofrontend/src/Pages/DebateRoom.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
- frontend/src/Pages/DebateRoom.tsx
🧰 Additional context used
🧬 Code graph analysis (1)
backend/controllers/auth.go (1)
backend/utils/email.go (2)
GenerateRandomCode(14-26)SendVerificationEmail(29-53)
🔇 Additional comments (1)
backend/controllers/auth.go (1)
196-219: Implementation correctly addresses previous review feedback.The conditional flow properly separates development (immediate JWT) from production (email verification) behavior. Error handling is present for both paths.
One consideration: if
SendVerificationEmailfails on line 210, the user has already been created but remains unverified. This is acceptable since the user can request verification resend, but you may want to log this scenario for monitoring.
|
Going through it........
…On Mon, Dec 29, 2025 at 10:17 AM coderabbitai[bot] ***@***.***> wrote:
***@***.***[bot]* commented on this pull request.
*Actionable comments posted: 1*
📜 Review details
*Configuration used*: defaults
*Review profile*: CHILL
*Plan*: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 37469fb
<37469fb>
and 7aa9543
<7aa9543>
.
📒 Files selected for processing (2)
- backend/controllers/auth.go
- frontend/src/Pages/DebateRoom.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
- frontend/src/Pages/DebateRoom.tsx
🧰 Additional context used 🧬 Code graph analysis (1) backend/controllers/auth.go
(1)
backend/utils/email.go (2)
- GenerateRandomCode (14-26)
- SendVerificationEmail (29-53)
🔇 Additional comments (1)
backend/controllers/auth.go (1)
196-219: *Implementation correctly addresses previous review feedback.*
The conditional flow properly separates development (immediate JWT) from
production (email verification) behavior. Error handling is present for
both paths.
One consideration: if SendVerificationEmail fails on line 210, the user
has already been created but remains unverified. This is acceptable since
the user can request verification resend, but you may want to log this
scenario for monitoring.
------------------------------
In backend/controllers/auth.go
<#148 (comment)>:
> + // Determine if we should auto-verify based on environment
+ isDevelopment := os.Getenv("ENV") == "development" || os.Getenv("ENV") == "local" || os.Getenv("ENV") == ""
+
+ // Generate verification code only if needed (production)
+ verificationCode := ""
+ if !isDevelopment {
+ verificationCode = utils.GenerateRandomCode(6)
+ }
*
|
7aa9543 to
859e47a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
backend/controllers/auth.go (2)
157-165: Security fix correctly implemented—now fails closed by default.The removal of the empty string check ensures that an unset or misconfigured
ENVvariable defaults to production behavior (requiring email verification), which is the secure approach. This addresses the previous security concern raised in past reviews.Optional: Add defensive logging when ENV is unset
To surface potential misconfigurations in production, consider logging a warning when
ENVis unset:// Determine if we should auto-verify based on environment env := os.Getenv("ENV") + if env == "" { + log.Println("Warning: ENV variable is unset, defaulting to production behavior") + } isDevelopment := env == "development" || env == "local"This helps operators detect configuration issues without compromising security.
197-220: Conditional flow correctly separates development and production signup paths.The implementation properly handles both environments:
- Development: Auto-verifies user, generates JWT immediately, enables instant login
- Production: Requires email verification, sends verification code, defers login until verified
Both paths include appropriate error handling and return suitable responses.
Optional: Add logging for email verification failures
When
SendVerificationEmailfails in production (line 211), the user record is already created but unverified, and the user never receives their verification code. Consider adding logging to monitor these failures:} else { // Send verification email in production err = utils.SendVerificationEmail(request.Email, verificationCode) if err != nil { + log.Printf("Failed to send verification email to %s: %v", request.Email, err) ctx.JSON(500, gin.H{"error": "Failed to send verification email", "message": err.Error()}) return }This aids operational monitoring and helps identify email delivery issues.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
backend/controllers/auth.gofrontend/src/Pages/DebateRoom.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
- frontend/src/Pages/DebateRoom.tsx
🧰 Additional context used
🧬 Code graph analysis (1)
backend/controllers/auth.go (1)
backend/utils/email.go (2)
GenerateRandomCode(14-26)SendVerificationEmail(29-53)
|
Need to have some changes into the code base, kind of optional
ones..........let me have them ok
…On Mon, Dec 29, 2025 at 10:24 AM coderabbitai[bot] ***@***.***> wrote:
***@***.***[bot]* commented on this pull request.
*Actionable comments posted: 0*
🧹 Nitpick comments (2)
backend/controllers/auth.go (2)
157-165: *Security fix correctly implemented—now fails closed by default.*
The removal of the empty string check ensures that an unset or
misconfigured ENV variable defaults to production behavior (requiring
email verification), which is the secure approach. This addresses the
previous security concern raised in past reviews.
Optional: Add defensive logging when ENV is unset
To surface potential misconfigurations in production, consider logging a
warning when ENV is unset:
// Determine if we should auto-verify based on environment
env := os.Getenv("ENV")+ if env == "" {+ log.Println("Warning: ENV variable is unset, defaulting to production behavior")+ }
isDevelopment := env == "development" || env == "local"
This helps operators detect configuration issues without compromising
security.
------------------------------
197-220: *Conditional flow correctly separates development and production
signup paths.*
The implementation properly handles both environments:
- *Development*: Auto-verifies user, generates JWT immediately,
enables instant login
- *Production*: Requires email verification, sends verification code,
defers login until verified
Both paths include appropriate error handling and return suitable
responses.
Optional: Add logging for email verification failures
When SendVerificationEmail fails in production (line 211), the user
record is already created but unverified, and the user never receives their
verification code. Consider adding logging to monitor these failures:
} else {
// Send verification email in production
err = utils.SendVerificationEmail(request.Email, verificationCode)
if err != nil {+ log.Printf("Failed to send verification email to %s: %v", request.Email, err)
ctx.JSON(500, gin.H{"error": "Failed to send verification email", "message": err.Error()})
return
}
This aids operational monitoring and helps identify email delivery issues.
📜 Review details
*Configuration used*: defaults
*Review profile*: CHILL
*Plan*: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 7aa9543
<7aa9543>
and 859e47a
<859e47a>
.
📒 Files selected for processing (2)
- backend/controllers/auth.go
- frontend/src/Pages/DebateRoom.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
- frontend/src/Pages/DebateRoom.tsx
🧰 Additional context used 🧬 Code graph analysis (1) backend/controllers/auth.go
(1)
backend/utils/email.go (2)
- GenerateRandomCode (14-26)
- SendVerificationEmail (29-53)
—
Reply to this email directly, view it on GitHub
<#148 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BIN27WXWPEPBSUW2UM4RPDL4ECXYJAVCNFSM6AAAAACQF4GWCOVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZTMMJVGA2DANBYGY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
859e47a to
e704d04
Compare
Changes
Files Changed
Summary by CodeRabbit
New Features
Bug Fixes
Style
✏️ Tip: You can customize this high-level summary in your review settings.