def decorator(*args, **kwargs): cups = kwargs.get('cups') if (cups and current_user.is_authenticated() and not current_user.allowed(cups, 'cups')): return current_app.login_manager.unauthorized() return func(*args, **kwargs)