Proje: Okul Platform · Hub: Okul Platform — Domain
OtpCode Model
Alanlar:
user_id→ User (opsiyonel — kayıtsız kullanıcı da OTP alabilir)value— E-posta veya telefon numarasıtype→ OtpCodeType (phoneveyaemail)code— OTP kodu (hidden - response’da gösterilmez)expires_at— Son kullanma tarihiverified_at— Doğrulama tarihiattempt_count— Hatalı deneme sayısıip_address, user_agent— İstek bilgileriref— Referans (neden OTP alındı)
Geçerlilik Kontrolleri
$otp->isValid() // expire olmamış + max_attempts aşılmamış
$otp->isExpired() // expires_at geçmişte miMax attempts: config('app_settings.otp_code.max_attempts')
Scope’lar
OtpCode::query()->active() // verified olmamış + expire olmamış
OtpCode::query()->expired() // expires_at geçmişOtpCodeType Enum
phone → SendOtpCodeSmsJob (Infobip üzerinden SMS)
email → SendOtpCodeEmailJob (mail üzerinden)
OTP Exceptions
OtpCodeException — Genel OTP hatası
OtpRateLimitExceededException — Rate limit (çok fazla deneme)
OtpDuplicateContactException — Aynı telefon/email birden fazla hesapta
OtpUserNotFoundException — Kullanıcı bulunamadı
Temizlik
CleanExpiredOtpCodesCommand — Süresi dolmuş OTP kodlarını siler.
Related
- api-auth-system — OTP ile login akışı
- api-sms-service — OTP SMS gönderimi
- api-user-contact-system — OTP için telefon/email kaynağı