from functools import wraps
from flask import session, redirect, url_for, flash

def admin_required(f):
    @wraps(f)
    def decorated_function(*args, **kwargs):
        if session.get('is_admin'):
            return f(*args, **kwargs)
        flash('Admin access required', 'warning')
        return redirect(url_for('admin.login'))
    return decorated_function
