mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-23 18:13:57 +03:00
26 lines
614 B
Python
26 lines
614 B
Python
import uuid
|
|
from django.db import models
|
|
|
|
class BaseToken(models.Model):
|
|
"""
|
|
The base abstract authorization token model class.
|
|
"""
|
|
key = models.CharField(max_length=32, primary_key=True, blank=True)
|
|
user = models.ForeignKey('auth.User')
|
|
revoked = models.BooleanField(default=False)
|
|
|
|
class Meta:
|
|
abstract=True
|
|
|
|
def save(self, *args, **kwargs):
|
|
if not self.key:
|
|
self.key = uuid.uuid4().hex
|
|
return super(BaseToken, self).save(*args, **kwargs)
|
|
|
|
|
|
class BasicToken(BaseToken):
|
|
"""
|
|
The default authorization token model class.
|
|
"""
|
|
pass
|