This commit is contained in:
2026-08-24 15:54:08 +03:30
commit 236002a87c
133 changed files with 5946 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
from rest_framework.throttling import SimpleRateThrottle
class PhoneRateThrottle(SimpleRateThrottle):
"""محدودیت درخواست OTP بر اساس شماره موبایل (نه IP) تا با یک شماره ثابت اسپم نشود"""
scope = "otp_send"
def get_cache_key(self, request, view):
phone = request.data.get("phone")
if not phone:
return None
return self.cache_format % {"scope": self.scope, "ident": phone}
class OTPVerifyThrottle(SimpleRateThrottle):
"""محدودیت تلاش برای تایید OTP بر اساس شماره موبایل، برای جلوگیری از brute force"""
scope = "otp_verify"
def get_cache_key(self, request, view):
phone = request.data.get("phone")
if not phone:
return None
return self.cache_format % {"scope": self.scope, "ident": phone}