feat: eigener benutzer per token abfragbar (/api/users/me)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
223eb4eb45
commit
db700fd003
2 files changed
+11
No files matched your search
@@ -13,6 +13,12 @@ class UserName(BaseModel):
|
|||||||
username: str
|
username: str
|
||||||
|
|
||||||
|
|
||||||
|
@router.get("/me", response_model=UserName)
|
||||||
|
def me(user: ApiUser) -> UserName:
|
||||||
|
"""Who a token belongs to (e.g. so the agent only takes over its owner's clips)."""
|
||||||
|
return UserName(id=user.id, username=user.username)
|
||||||
|
|
||||||
|
|
||||||
@router.get("", response_model=list[UserName])
|
@router.get("", response_model=list[UserName])
|
||||||
def list_user_names(user: ApiUser, db: DbSession) -> list[UserName]:
|
def list_user_names(user: ApiUser, db: DbSession) -> list[UserName]:
|
||||||
"""Names of the other active users, for sharing projects; nothing else is revealed."""
|
"""Names of the other active users, for sharing projects; nothing else is revealed."""
|
||||||
|
|||||||
@@ -239,3 +239,8 @@ def test_latest_clip_ignores_pinning_and_files(agent):
|
|||||||
agent.post("/api/files", params={"name": "newer.txt"}, content=b"file")
|
agent.post("/api/files", params={"name": "newer.txt"}, content=b"file")
|
||||||
|
|
||||||
assert agent.get("/api/clips/latest").json()["content"] == "newest text"
|
assert agent.get("/api/clips/latest").json()["content"] == "newest text"
|
||||||
|
|
||||||
|
|
||||||
|
def test_token_knows_its_user(agent, db):
|
||||||
|
anna = db.query(User).filter_by(username="anna").one()
|
||||||
|
assert agent.get("/api/users/me").json() == {"id": anna.id, "username": "anna"}
|
||||||
Reference in new issue
Block a user