Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
f8cda8ad
Commit
f8cda8ad
authored
Feb 01, 2014
by
Matthew King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Generate random token directly
parent
74fc6d8f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
4 deletions
+3
-4
rest_framework/authtoken/models.py
+3
-4
No files found.
rest_framework/authtoken/models.py
View file @
f8cda8ad
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):
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment