fix: token refresh and seed tree visibility
Fix broken JWT token refresh that caused "Failed to load trees" after idle timeout. The refresh endpoint expected token as query param but frontend sent it as Authorization header. Added proper dependency (get_refresh_token_payload) and refresh queue to handle concurrent 401s. Also fix seed trees not being visible to non-admin users by updating the seed script to set is_public/is_default on existing trees. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3327,19 +3327,29 @@ async def create_tree(client: httpx.AsyncClient, token: str, tree_data: dict) ->
|
||||
"""Create a tree via the API. Returns None if tree already exists."""
|
||||
headers = {"Authorization": f"Bearer {token}"}
|
||||
|
||||
# Mark as default/system tree (public and visible to all)
|
||||
tree_data["is_default"] = True
|
||||
tree_data["is_public"] = True
|
||||
|
||||
# Check if tree with same name exists
|
||||
list_response = await client.get(f"{API_BASE_URL}/trees", headers=headers)
|
||||
if list_response.status_code == 200:
|
||||
existing_trees = list_response.json()
|
||||
for tree in existing_trees:
|
||||
if tree["name"] == tree_data["name"]:
|
||||
# Ensure existing trees have correct visibility flags
|
||||
if not tree.get("is_public") or not tree.get("is_default"):
|
||||
patch_response = await client.put(
|
||||
f"{API_BASE_URL}/trees/{tree['id']}",
|
||||
json={"is_public": True, "is_default": True},
|
||||
headers=headers
|
||||
)
|
||||
if patch_response.status_code == 200:
|
||||
print(f" [UPDATE] Tree '{tree_data['name']}' visibility updated (ID: {tree['id']})")
|
||||
return None
|
||||
print(f" [SKIP] Tree '{tree_data['name']}' already exists (ID: {tree['id']})")
|
||||
return None
|
||||
|
||||
# Mark as default/system tree (public and visible to all)
|
||||
tree_data["is_default"] = True
|
||||
tree_data["is_public"] = True
|
||||
|
||||
# Create the tree
|
||||
response = await client.post(
|
||||
f"{API_BASE_URL}/trees",
|
||||
|
||||
Reference in New Issue
Block a user