From 8488bee488c43d866d030b9bec8597292b8091fd Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Mon, 7 Apr 2014 20:07:08 -0300 Subject: [PATCH] added the forced json into the request and removed unused function --- luncho/helpers.py | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/luncho/helpers.py b/luncho/helpers.py index 06dcd0e..f6b6c54 100644 --- a/luncho/helpers.py +++ b/luncho/helpers.py @@ -41,6 +41,7 @@ class ForceJSON(object): if missing: raise MissingFieldsException(missing) + request.as_json = json # replace with a forced json return func(*args, **kwargs) return check_json @@ -70,23 +71,3 @@ def auth(func): return func(*args, **kwargs) return check_auth - - -def user_from_token(token): - """Returns a tuple with the user that owns the token and the error. If the - token is valid, user will have the user object and error will be None; if - there is something wrong with the token, the user will be None and the - error will have a Response created with :py:func:`JSONError`. - - :param token: The token received - :type token: str - - :return: Tuple with the user and the error.""" - user = User.query.filter_by(token=token).first() - if not user: - raise UserNotFoundException() - - if not user.valid_token(token): - raise InvalidTokenException() - - return user