def require_login(f):
    """Decorator for methods that require login."""

    def wrapper(instance, *args, **kwargs):
        if not instance.logged_in:
            instance.login()
            instance.logged_in = True
        return f(instance, *args, **kwargs)

    return wrapper