# Path: catsnap/web/formatted_routes.py
# def abort(request_format, code, message=None):
#     if request_format == 'json':
#         flask_abort(make_response(json.dumps({'error': message, 'status': 'error'}),
#                                   code,
#                                   {'Content-Type': 'application/json'}))
#     else:
#         flask_abort(make_response(message, code))


from functools import wraps
from catsnap.web.formatted_routes import abort
from flask import g, redirect
from __future__ import unicode_literals



def is_logged_in():
    return g.user is not None


def login_required(fn):
    @wraps(fn)
    def wrapper(request_format, *args, **kwargs):
        if g.user is None:
            if request_format == 'html':
                return redirect('/')
            else:

# Path: catsnap/web/formatted_routes.py
# def abort(request_format, code, message=None):
#     if request_format == 'json':
#         flask_abort(make_response(json.dumps({'error': message, 'status': 'error'}),
#                                   code,
#                                   {'Content-Type': 'application/json'}))
#     else:
#         flask_abort(make_response(message, code))


# Path: catsnap/web/utils.py
from functools import wraps
from catsnap.web.formatted_routes import abort
from flask import g, redirect

from __future__ import unicode_literals



def is_logged_in():
    return g.user is not None


def login_required(fn):
    @wraps(fn)
    def wrapper(request_format, *args, **kwargs):
        if g.user is None:
            if request_format == 'html':
                return redirect('/')
            else:

                abort(request_format, 401, "You must log in to do that.")