Skip to content

Commit 98cb82b

Browse files
committed
Added unique constrain user and device_id
1 parent c5d753d commit 98cb82b

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
# Generated by Django 3.2.18 on 2024-10-17 05:42
1+
# Generated by Django 3.2.18 on 2024-10-17 07:16
22

3+
from django.conf import settings
34
from django.db import migrations
45

56

67
class Migration(migrations.Migration):
78

89
dependencies = [
10+
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
911
('authtoken', '0004_auto_20240927_1224'),
1012
]
1113

@@ -14,5 +16,9 @@ class Migration(migrations.Migration):
1416
model_name='token',
1517
name='unique_device_id_not_null_blank',
1618
),
19+
migrations.AlterUniqueTogether(
20+
name='token',
21+
unique_together={('user', 'device_id')},
22+
),
1723
]
1824

drfpasswordless/authtoken/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class Meta:
4242
abstract = 'drfpasswordless.authtoken' not in settings.INSTALLED_APPS
4343
verbose_name = _("Token")
4444
verbose_name_plural = _("Tokens")
45+
unique_together = (('user', 'device_id'),)
4546

4647
def save(self, *args, **kwargs):
4748
if not self.key:

0 commit comments

Comments
 (0)