Properly catch wrong signature exception.

remotes/origin/enhancement/email-actions
Andrey Antukh 2013-10-23 15:00:38 +02:00
parent fa2864ba19
commit 8fbd7e2e07
1 changed files with 6 additions and 1 deletions

View File

@ -37,8 +37,13 @@ def get_token_for_user(user):
def get_user_for_token(token): def get_user_for_token(token):
try:
data = signing.loads(token) data = signing.loads(token)
except signing.BadSignature:
raise exc.BadRequest("Invalid token")
model_cls = get_model("users", "User") model_cls = get_model("users", "User")
try: try:
user = model_cls.objects.get(pk=data["user_id"]) user = model_cls.objects.get(pk=data["user_id"])
except model_cls.DoesNotExist: except model_cls.DoesNotExist: