mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-03 20:10:10 +03:00
When settings.SECRET_KEY is set, also use this to generate key
This commit is contained in:
parent
822eb39599
commit
37150d710c
|
@ -34,6 +34,9 @@ class Token(models.Model):
|
|||
return super(Token, self).save(*args, **kwargs)
|
||||
|
||||
def generate_key(self):
|
||||
if hasattr(settings, 'SECRET_KEY') and len(settings.SECRET_KEY):
|
||||
return sha1('%s%s' % (settings.SECRET_KEY, binascii.hexlify(os.urandom(20))).hexdigest())
|
||||
|
||||
return binascii.hexlify(os.urandom(20))
|
||||
|
||||
def __unicode__(self):
|
||||
|
|
Loading…
Reference in New Issue
Block a user