def user_to_dict(user):
    """
    Convert an instance of the User model to a dict.

    :param user:  An instance of the User model.
    :return:      A dict representing the user.
    """
    return {
        'id': user.id,
        'demoId': user.demoId,
        'email': user.email,
        'username': user.username,
        'roles': user.roles
    }