feat(users): add google oauth login flow
This commit is contained in:
@@ -69,3 +69,34 @@ class LoginAttempt(BaseModel):
|
||||
|
||||
def __str__(self):
|
||||
return f"LoginAttempt for User: {self.user} ({'✅' if self.status else '❌'})"
|
||||
|
||||
|
||||
class UserSocialAccount(BaseModel):
|
||||
class ProviderType(models.TextChoices):
|
||||
GOOGLE = "google", "google"
|
||||
|
||||
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name="social_accounts")
|
||||
provider = models.CharField(max_length=32, choices=ProviderType.choices)
|
||||
provider_user_id = models.CharField(max_length=255)
|
||||
email = models.EmailField(blank=True, default="")
|
||||
email_verified = models.BooleanField(default=False)
|
||||
avatar_url = models.URLField(blank=True, default="")
|
||||
|
||||
class Meta:
|
||||
verbose_name = "user_social_account"
|
||||
verbose_name_plural = "user_social_accounts"
|
||||
db_table = "user_social_account"
|
||||
ordering = ("-updated_at", "-created_at")
|
||||
constraints = (
|
||||
models.UniqueConstraint(
|
||||
fields=("provider", "provider_user_id"),
|
||||
name="user_social_account_provider_uid_uniq",
|
||||
),
|
||||
)
|
||||
indexes = (
|
||||
models.Index(fields=["provider", "provider_user_id"], name="user_social_provider_uid_idx"),
|
||||
models.Index(fields=["provider", "email"], name="user_social_provider_email_idx"),
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.provider}:{self.provider_user_id}"
|
||||
|
||||
Reference in New Issue
Block a user