AOSSIE-Org / AOSSIE-Org/Resonate

Sign-Up button allows multiple taps causing duplicate API calls & "User already exists" error

Aperta
#612 18 commenti 0 reazioni 1 assegnatario Rivendicata da @dolliecoder Vedi su GitHub
enhancement
Lingua principale
Dart
Stelle
344
Fork
350
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

### 🐛 Describe the bug

### 🐞 Bug Report: Multiple Sign-Up API Calls Due to Rapid Button Taps

#### **Description**
During sign-up, if the user taps the **Sign Up** button multiple times quickly, the app sends multiple API requests to Appwrite.
The first request successfully creates the user, but the subsequent requests fail with:

> "User already exists"

This causes poor UX and unnecessary backend load.

---
### 🎥 Attached Video
[signup_limiter_error.mp4](https://streamable.com/8kdvlt)

---

### **Steps to Reproduce**
1. Open the Sign-Up screen.
2. Enter valid name/email/password.
3. Tap the **Sign Up** button rapidly multiple times.
4. Observe that multiple API calls are triggered.
5. The app eventually shows "User already exists" even though sign-up succeeded on the first tap.

---

### **Expected Behavior**
- After the first tap:
- The **Sign Up** button should be disabled.
- A loading indicator should be shown.
- Further taps must be ignored.
- Only **one** sign-up API call should be allowed at a time.

---

### **Actual Behavior**
- Button remains clickable during the sign-up API call.
- Multiple requests are sent.
- First request creates the user.
- Following requests fail → *“User already exists”*.
- No loading feedback or tap lock is shown to the user.

---

### ✔ Proposed Production-Quality Fix

A simple button-disable helps, but a more reliable and scalable fix is recommended to prevent
multiple API calls and "User already exists" errors.

#### ✅ 1. Add an atomic processing lock at controller/viewmodel level
This prevents multiple parallel API calls even if the UI rebuilds.

```dart
class SignupController {
bool _isProcessing = false;

Future signupUser() async {
if (_isProcessing) return; // HARD LOCK

_isProcessing = true;
try {
await AppwriteAuth.signup(); // API call
} finally {
_isProcessing = false;
}
}
}

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.