diff options
author | Milo Casagrande <milo.casagrande@linaro.org> | 2014-10-15 21:01:34 +0200 |
---|---|---|
committer | Milo Casagrande <milo.casagrande@linaro.org> | 2014-10-15 21:01:34 +0200 |
commit | 4ed4b29d06428f4d831b214868b0887a2b5b43fb (patch) | |
tree | 690782199691aae69d9a459f7cd0a15196b24d5b /app/handlers/token.py | |
parent | 65564cf3f8108a9f71f81b8f203c2c127e75a91d (diff) |
handlers: Use the newly defined keys and values.
* Refactor handlers code to use the newly defined keys.
Change-Id: Ib14578bd1f2a57297b2296a0c1d12824700c9f2e
Diffstat (limited to 'app/handlers/token.py')
-rw-r--r-- | app/handlers/token.py | 41 |
1 files changed, 7 insertions, 34 deletions
diff --git a/app/handlers/token.py b/app/handlers/token.py index 822266d..f73ab73 100644 --- a/app/handlers/token.py +++ b/app/handlers/token.py @@ -24,29 +24,27 @@ from tornado.web import ( from urlparse import urlunparse from handlers.base import BaseHandler -from handlers.common import get_query_fields +from handlers.common import ( + TOKEN_VALID_KEYS, + get_query_fields, +) from handlers.decorators import protected_th from handlers.response import HandlerResponse from models import ( ADMIN_KEY, - CREATED_KEY, DELETE_KEY, EMAIL_KEY, - EXPIRED_KEY, EXPIRES_KEY, GET_KEY, IP_ADDRESS_KEY, IP_RESTRICTED, POST_KEY, - PROPERTIES_KEY, SUPERUSER_KEY, + TOKEN_COLLECTION, TOKEN_KEY, USERNAME_KEY, ) -from models.token import ( - TOKEN_COLLECTION, - Token, -) +from models.token import Token from utils.db import ( delete, find_one, @@ -66,32 +64,7 @@ class TokenHandler(BaseHandler): return self.db[TOKEN_COLLECTION] def _valid_keys(self, method): - valid_keys = { - 'POST': [ - ADMIN_KEY, - DELETE_KEY, - EMAIL_KEY, - EXPIRES_KEY, - GET_KEY, - IP_ADDRESS_KEY, - IP_RESTRICTED, - POST_KEY, - SUPERUSER_KEY, - USERNAME_KEY, - ], - 'GET': [ - CREATED_KEY, - EMAIL_KEY, - EXPIRED_KEY, - EXPIRES_KEY, - IP_ADDRESS_KEY, - PROPERTIES_KEY, - TOKEN_KEY, - USERNAME_KEY, - ], - } - - return valid_keys.get(method, None) + return TOKEN_VALID_KEYS.get(method, None) @protected_th("GET") @asynchronous |