Remove the guest system entirely: no is_guest/device_id, no guest throttles, phone login is the only way in
accounts.0008 drops the columns and refuses to run while guest rows exist. Docs describe the current state; tests that only proved guest behaviour are gone. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,7 +5,7 @@ from django.db import models
|
||||
|
||||
class User(models.Model):
|
||||
"""
|
||||
کاربر اصلی سیستم (مهمان یا ثبتنامشده با شماره).
|
||||
کاربر اصلی سیستم: ثبتنامشده با شمارهی موبایل (تنها راه ورود).
|
||||
توجه: این مدل، AUTH_USER_MODEL جنگو نیست؛ یک مدل بیزنسی مستقله که
|
||||
با TadrisinoTokenAuthentication سفارشی احراز هویت میشه.
|
||||
|
||||
@@ -13,14 +13,11 @@ class User(models.Model):
|
||||
این اپ عمداً هیچوقت FK واقعی به مدل اپ دیگه نمیزنه.
|
||||
"""
|
||||
phone = models.CharField(max_length=15, unique=True, null=True, blank=True, db_index=True)
|
||||
device_id = models.CharField(max_length=64, null=True, blank=True, db_index=True)
|
||||
name = models.CharField(max_length=100, blank=True)
|
||||
avatar = models.CharField(max_length=100, blank=True)
|
||||
is_guest = models.BooleanField(default=True)
|
||||
grade_id = models.IntegerField(null=True, blank=True) # ارجاع سبک به content.Grade
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
# آخرین زمانِ فعالیتِ کاربر (لاگین موفق، رفرش توکن موفق، یا سشنِ
|
||||
# مهمانِ واقعی). فقط برای هدفگیریِ آیندهی کمپینهای پیامی نگهداری
|
||||
# آخرین زمانِ فعالیتِ کاربر (لاگین موفق یا رفرش توکن موفق). فقط برای هدفگیریِ آیندهی کمپینهای پیامی نگهداری
|
||||
# میشه؛ در حال حاضر هیچ منطقِ دیگهای به این فیلد وابسته نیست.
|
||||
last_activity_at = models.DateTimeField(null=True, blank=True)
|
||||
# access tokenهای صادرشده پیش از این لحظه رد میشوند (خروج از حساب). توکنِ
|
||||
@@ -30,17 +27,9 @@ class User(models.Model):
|
||||
|
||||
class Meta:
|
||||
ordering = ['-created_at']
|
||||
constraints = [
|
||||
# جلوگیری از ساخت دو کاربر مهمان همزمان با یک device_id یکسان.
|
||||
models.UniqueConstraint(
|
||||
fields=['device_id'],
|
||||
condition=models.Q(is_guest=True) & ~models.Q(device_id=None) & ~models.Q(device_id=''),
|
||||
name='uniq_guest_device_id',
|
||||
),
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return self.name or self.phone or f"guest-{self.pk}"
|
||||
return self.name or self.phone or f"user-{self.pk}"
|
||||
|
||||
@property
|
||||
def is_authenticated(self):
|
||||
@@ -77,7 +66,6 @@ class Session(models.Model):
|
||||
"""
|
||||
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='sessions')
|
||||
refresh_token = models.CharField(max_length=200, unique=True)
|
||||
device_id = models.CharField(max_length=64, blank=True)
|
||||
expires_at = models.DateTimeField()
|
||||
revoked = models.BooleanField(default=False)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user