Skip to content

Commit

Permalink
Return an error when token/new is not accessed via POST, fixes #2
Browse files Browse the repository at this point in the history
  • Loading branch information
jpulgarin committed Aug 31, 2011
1 parent c155205 commit 9414ed0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tokenapi/views.py
Expand Up @@ -17,13 +17,14 @@ def token_new(request):
password=request.POST['password'])
if user:
data = {
'success': True,
'token': token_generator.make_token(user),
'user': user.pk,
}
return JSONResponse(data)
else:
return JSONError("Unable to log you in, please try again")
return JSONError("Unable to log you in, please try again.")
else:
return JSONError("Must access via a POST request.")

# Checks if a given token and user pair is valid
# token/:token/:user.json
Expand All @@ -37,7 +38,6 @@ def token(request, token, user):
return JSONError("User does not exist.")
if token_generator.check_token(user,
token):
data['success'] = True
return JSONResponse({})
else:
return JSONError("Token did not match user.")
return JSONResponse(data)

0 comments on commit 9414ed0

Please sign in to comment.