Skip to content

Commit

Permalink
Add non-empty constraint for UserSocialAuth uid
Browse files Browse the repository at this point in the history
Any empty uids are surely erroneous, and better to have integrity errors
than having users start sharing accounts when logging in.
  • Loading branch information
aleksanb committed Mar 22, 2024
1 parent c50bc4a commit 2a4d46a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 5.0.3 on 2024-03-21 16:01

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("social_django", "0015_rename_extra_data_new_usersocialauth_extra_data"),
]

operations = [
migrations.AddConstraint(
model_name="UserSocialAuth",
constraint=models.CheckConstraint(
check=models.Q(("uid", ""), _negated=True),
name="user_social_auth_uid_required",
),
),
]
5 changes: 5 additions & 0 deletions social_django/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ class Meta:
app_label = "social_django"
unique_together = ("provider", "uid")
db_table = "social_auth_usersocialauth"
constraints = [
models.CheckConstraint(
check=~models.Q(uid=""), name="user_social_auth_uid_required"
),
]


class Nonce(models.Model, DjangoNonceMixin):
Expand Down

0 comments on commit 2a4d46a

Please sign in to comment.