Proje: Okul Platform · Hub: Okul Platform — Domain
OtpCodeService
app/Services/Bases/OtpCodeService.php
generateOtp() Akışı
-
Normalizasyon: E-posta → unchanged, telefon →
getPhoneNakedWithDigit_11() -
IP Rate Limit:
validateIpRateLimit()— Çok fazla istek engellemek için -
UserContact Kontrolü:
- Kayıt yok →
OtpUserNotFoundException - Birden fazla kullanıcıya bağlı →
OtpDuplicateContactException - Tek kullanıcı → OTP oluştur
- Kayıt yok →
-
OTP Oluşturma:
Cache::lock()ile concurrent request koruması (lock timeout →LockTimeoutException) -
OTP Gönderme:
sendOtp()→OtpCodeType::getJobByType()→SendOtpCodeSmsJobveyaSendOtpCodeEmailJob
verifyOtp() Akışı
findActiveByValue()→ Aktif OTP bul- Yok → expired exception
isValid()→ max_attempts kontrolüHash::check(code, otp.code)→ Bcrypt ile kod doğrulama- Yanlış →
incrementAttempt()+ kalan deneme sayısını bildir - Sıfır kalan → “maximum_exceeded”
- Doğru →
markAsUsed()
Güvenlik Özellikleri
- OTP kod hash’lenmiş saklanır (Bcrypt)
- IP bazlı rate limiting
- Cache lock ile concurrent istek önleme
- Max attempts ile brute force engeli
temizlik
cleanExpiredOtpCodes() → CleanExpiredOtpCodesCommand tarafından çağrılır.
Related
- api-otp-code-system — OtpCode model
- api-auth-service-detail — Login’de OTP kullanımı