Commit 3add26ec authored by Chris Lamb's avatar Chris Lamb
Browse files

Add ability to sign/unsign arbitrary data in get_token. (Ref: 27)

parent 843f6cf4
......@@ -4,8 +4,11 @@ from django.core.signing import TimestampSigner, BadSignature
UserModel = get_user_model()
def get_token(user):
return TimestampSigner(salt=user.password).sign(
def get_token(user, *args):
keys = []
return TimestampSigner(salt=user.password).sign(':'.join(keys))
def get_user_from_token(token):
......@@ -22,3 +25,13 @@ def get_user_from_token(token):
return None
return user
def get_value_from_token(token, idx):
parts = token.split(':')
# Ensure we have enough values
if len(parts) < 4 + idx:
return None
return parts[idx + 1]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment