AOSSIE-Org / AOSSIE-Org/DebateAI

[BUG]: Orphaned User Documents on Failed Email Send

Aperta
#496 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
bug
Lingua principale
TypeScript
Stelle
84
Fork
198
Merge medio
2g 19h
PR unite (30g)
30

Descrizione

### Bug Description

When signup fails due to a SendVerificationEmail error, the user document is already persisted in MongoDB with isVerified: false. No rollback is performed, so the email address is permanently "taken" — the user can't log in (blocked by the !IsVerified check) and can't re-register ("User already exists")

### Steps to Reproduce

1 . Set invalid SMTP credentials.
2 . POST /api/auth/signup with a new email → returns HTTP 500.
3 . Repeat the same request → returns HTTP 400 "User already exists"

Actual Behavior
User is permanently locked out of that email address. Recovery requires manual deleteOne in MongoDB

Expected Behavior
If the email send fails, the user document should be rolled back so the user can re-register freely

### Logs and Screenshots

Image

Terminal Log :

[GIN] 2026/09/13 - 14:08:37 | 204 | 984.3µs | ::1 | OPTIONS "/signup"
[GIN] 2026/09/13 - 14:08:41 | 500 | 3.9518977s | ::1 | POST "/signup"

### Environment Details

- Component: backend/controllers/auth.go — SignUp() — Lines 194–209
- Database: MongoDB
- Mail: SMTP (Gmail)
- Framework: Go / Gin

### Impact

High - Major feature is broken

### Code of Conduct

- [x] I have joined the [Discord server](https://discord.gg/hjUhu33uAn) and will post updates there
- [x] I have searched existing issues to avoid duplicates

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Start in backend/controllers/auth.go at SignUp() around lines 194–209, then reproduce the failure with invalid SMTP credentials and inspect whether the MongoDB user document remains. Done means a failed SendVerificationEmail leaves no unusable user record, and repeating POST /api/auth/signup with the same email can proceed without "User already exists".

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
go, mongodb
Ambito
authentication, backend, databases
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Attiva
Chiarezza
Specificata chiaramente
Idoneità per principianti
76/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.