from functools import wraps

from flask import session, flash, redirect, url_for

from app.log import get_logger

logger = get_logger(__name__)

# Login required decorator
def login_required(f):
    @wraps(f)
    def wrap(*args, **kwargs):
        if "logged_in" in session:
            return f(*args, **kwargs)
        else:
            flash("You need to login first.")
            return redirect(url_for("login"))

    return wrap

from functools import wraps

from flask import session, flash, redirect, url_for

from app.log import get_logger

logger = get_logger(__name__)

# Login required decorator
def login_required(f):
    @wraps(f)
    def wrap(*args, **kwargs):
        if "logged_in" in session:
            return f(*args, **kwargs)
        else:
            flash("You need to login first.")
            return redirect(url_for("login"))

    return wrap

# Login required decorator