feat(dimentorin): mentor stats endpoint public - total sessions, unique mentees, avg rating
- GET /mentors/{id}/stats (public, no auth)
- resolve mentor profile id -> user id in get_mentor_sessions (FK uses app_users.id)
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
# Dimentorin — Catatan Temuan Infra (Dev Audit, 2026-08-04)
|
||||
|
||||
Dokumen ini mencatat temuan yang membutuhkan perhatian tim sebelum produksi.
|
||||
Semua diuji lokal (Postgres `dimentorin`, backend :4099).
|
||||
|
||||
## 1. SMTP email verification broken (blocker aktivasi user baru)
|
||||
|
||||
- Endpoint `POST /v1/iam/auth/send-otp` gagal: `SMTP transport error (535): Username and Password not accepted` — kredensial `.env` (`SMTP_EMAIL=dev@example.com`, `SMTP_PASSWORD=dev`) ditolak Google SMTP.
|
||||
- `POST /v1/iam/auth/verify-email` tetap butuh OTP untuk memanggil, tapi lihat poin 2.
|
||||
- **Dampak**: mentee/mentor baru tak bisa menerima OTP lewat email → tak bisa aktivasi → tak bisa login, kecuali via verify-email langsung.
|
||||
- **Diperlukan**: SMTP credential institution yang valid (Gmail App Password atau SMTP relay), sebaiknya dari BWS secret management, bukan hardcode.
|
||||
|
||||
## 2. verify-email TIDAK memverifikasi OTP (security issue)
|
||||
|
||||
`imphnen-iam/src/auth/application/mod.rs` → `verify_email()`:
|
||||
|
||||
```rust
|
||||
async fn verify_email(&self, payload: VerifyEmailInput) -> ... {
|
||||
let user = ...find_by_email...;
|
||||
if user.is_active { return Err(...); }
|
||||
self.user_repo.update(UserEntity { is_active: true, ..user }).await?;
|
||||
Ok(())
|
||||
}
|
||||
```
|
||||
|
||||
- OTP di-generate (`OtpManager::generate_otp`) + dikirim via email, TAPI **`payload.otp` tidak pernah divalidasi**.
|
||||
- `OtpManager::validate_otp` ada tapi tak dipanggil di handler ini.
|
||||
- **Dampak**: siapa pun yang tahu email bisa mengaktifkan akun dengan otp sembarang. Verifikasi email berbasis kepemilikan = tidak ada.
|
||||
- **Fix yang disarankan**: `verify_email` harus menyimpan `OtpData` (hash+expiry) saat kirim, lalu memanggil `OtpManager::validate_otp(stored, payload.otp)` sebelum set `is_active`.
|
||||
|
||||
## 3. (OK, sudah benar) Register mentor + booking
|
||||
|
||||
- `POST /v1/dimentorin/mentors/create` → 200, user + mentor profile dibuat, status `pending`, user tak tampil di list public sampai verified.
|
||||
- `POST /v1/dimentorin/mentors/{id}/sessions/create` → 200, session pending.
|
||||
- Kedua endpoint fungsional setelah fix UUID (commit 9b5efef).
|
||||
|
||||
## Rekomendasi
|
||||
|
||||
Tangani #1 dan #2 sebelum go-live. #2 adalah kelas bug "OTP di-generate tapi tak dipakai" — sisi verifikasi email saat ini tidak lebih dari form "set is_active=true tanpa autentikasi".
|
||||
Reference in New Issue
Block a user