feat(users): add google oauth login flow
This commit is contained in:
@@ -83,6 +83,35 @@ class ScopedMobileThrottle(SimpleRateThrottle):
|
||||
return allowed
|
||||
|
||||
|
||||
class ScopedFlowMobileThrottle(ScopedMobileThrottle):
|
||||
def get_mobile_identifier(self, request) -> str | None:
|
||||
mobile = super().get_mobile_identifier(request)
|
||||
if mobile:
|
||||
return mobile
|
||||
|
||||
try:
|
||||
flow = request.data.get("flow")
|
||||
except Exception:
|
||||
flow = None
|
||||
|
||||
if not isinstance(flow, str) or not flow:
|
||||
return None
|
||||
|
||||
try:
|
||||
from apps.users.services.google_oauth import get_google_flow
|
||||
|
||||
flow_payload = get_google_flow(flow)
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
mobile = flow_payload.get("mobile")
|
||||
if not isinstance(mobile, str):
|
||||
return None
|
||||
|
||||
normalized = "".join(ch for ch in mobile if ch.isdigit())
|
||||
return normalized or None
|
||||
|
||||
|
||||
class OTPSendBurstThrottle(ScopedMobileThrottle):
|
||||
scope = "otp_send_burst"
|
||||
|
||||
@@ -97,3 +126,15 @@ class PasswordLoginThrottle(ScopedMobileThrottle):
|
||||
|
||||
class OTPLoginThrottle(ScopedMobileThrottle):
|
||||
scope = "login_otp"
|
||||
|
||||
|
||||
class GoogleClaimSendBurstThrottle(ScopedFlowMobileThrottle):
|
||||
scope = "otp_send_burst"
|
||||
|
||||
|
||||
class GoogleClaimSendSustainedThrottle(ScopedFlowMobileThrottle):
|
||||
scope = "otp_send_sustained"
|
||||
|
||||
|
||||
class GoogleClaimVerifyThrottle(ScopedFlowMobileThrottle):
|
||||
scope = "login_otp"
|
||||
|
||||
Reference in New Issue
Block a user