mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-03 05:04:31 +03:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
f16ad26368
|
@ -1,5 +1,5 @@
|
||||||
import uuid
|
import binascii
|
||||||
import hmac
|
import os
|
||||||
from hashlib import sha1
|
from hashlib import sha1
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
@ -34,8 +34,7 @@ class Token(models.Model):
|
||||||
return super(Token, self).save(*args, **kwargs)
|
return super(Token, self).save(*args, **kwargs)
|
||||||
|
|
||||||
def generate_key(self):
|
def generate_key(self):
|
||||||
unique = uuid.uuid4()
|
return binascii.hexlify(os.urandom(20))
|
||||||
return hmac.new(unique.bytes, digestmod=sha1).hexdigest()
|
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return self.key
|
return self.key
|
||||||
|
|
Loading…
Reference in New Issue
Block a user