def server_auth(original_function):
    """
    server access authentication
    request should include username and access token
    attaches user object to request if successful
    :param original_function:
    :return:
    """
    def wrapper(request):
        return original_function(request)
        username=u""
        token=u""
        try:
            username = request.GET['username']
            token = request.GET['token']
        except:
            username = request.POST['username']
            token = request.POST['token']

        if not (username and token):
            return error_response("Please provide username and access token for authentication")

        authorized = verify_token(username=username, token=token)

        if authorized==1:
            user=User.objects.get(username=username)
            request.user=user
            return original_function(request)
        elif authorized==-1:
            return error_response("expired token")
        elif authorized==0:
            return error_response("Authentication error")

    return wrapper