Skip to content

feat: add current param to deleteSessions endpoint - #13990

Merged
Meldiron merged 2 commits into
appwrite:mainfrom
jaysomani:feat/delete-sessions-current-param-fresh
Sep 29, 2026
Merged

Meldiron merged 2 commits into
appwrite:mainfrom
jaysomani:feat/delete-sessions-current-param-fresh

Conversation

@jaysomani

Copy link
Copy Markdown
Contributor

Adds optional bool param current (default true) to DELETE /account/sessions. When false, all sessions except the calling session are deleted, allowing sign-out everywhere while staying signed in on the current device.

Uses the session resource from #13900 so JWT auth works correctly for both cookie and JWT authenticated callers.

X-Fallback-Cookies header is now only sent when current=true to avoid wiping the caller's stored session cookie when signing out other sessions.

E2E tests cover cookie and JWT auth paths with three-session setup per spec: other two sessions get 401, calling session stays 200, listSessions returns exactly one session marked current.

What does this PR do?

(Provide a description of what this PR does and why it's needed.)

Test Plan

(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Screenshots may also be helpful.)

Related PRs and Issues

  • (Related PR or issue)

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?

Adds optional bool param current (default true) to DELETE /account/sessions.
When false, all sessions except the calling session are deleted, allowing
sign-out everywhere while staying signed in on the current device.

Uses the session resource from appwrite#13900 so JWT auth works correctly for
both cookie and JWT authenticated callers.

X-Fallback-Cookies header is now only sent when current=true to avoid
wiping the caller's stored session cookie when signing out other sessions.

E2E tests cover cookie and JWT auth paths with three-session setup
per spec: other two sessions get 401, calling session stays 200,
listSessions returns exactly one session marked current.
@ghost

ghost commented Sep 29, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The new guard and test assertion are correct and I found no issues.

This adds an optional boolean current parameter (default true) to DELETE /v1/account/sessions. With current=false, the calling session is kept and every other session is deleted. The caller is identified through the existing session resource, so cookie and JWT auth both work. The X-Fallback-Cookies reset header is only sent when current=true. The reference doc is updated, and two E2E tests cover the cookie and JWT paths.

Latest changes: Added a guard that throws USER_SESSION_NOT_FOUND when current=false and there is no calling session (for example an API key), so it no longer deletes every session. Also added an E2E assertion that the x-fallback-cookies header is absent when current=false.

Verdict New comments Fixed Still open
💬 Commented 0 0 0

Note

@jaysomani does not have write access to this repository, so Hansi does not approve automatically. A maintainer can review and approve.

📂 Walkthrough · 3
File Change
app/controllers/api/account.php Adds the current boolean param and injects the session resource. With current=false the calling session is skipped, and the request now fails with USER_SESSION_NOT_FOUND when no calling session exists. The fallback-cookie reset header is sent only when current=true.
docs/references/account/delete-sessions.md Documents the current option.
tests/e2e/Services/Account/AccountCustomClientTest.php Adds cookie and JWT E2E tests for keeping the current session, plus a helper for extra sessions. The cookie test now also asserts that x-fallback-cookies is absent.

Reviewed the commits since 66242cf · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Tier S · Looks good to merge. Summary

@greptile-apps

greptile-apps Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[Medium risk] Adds optional parameter to session deletion endpoint.

The PR does not appear safe to merge because the previously reported query-string request still signs out a caller intending to keep its session.

Fix All in Claude CodeFindings

  1. P1 Query flag is ignored ▶
  2. P2 Fallback cookie behavior is untested ▶
Fix with agent prompt
### Issue 1
app/controllers/api/account.php:undefined-651
For DELETE requests, the API specification tells clients to send `current` in the query string, but the server reads DELETE parameters from the body. A client sending `current=false` as specified gets the default `true` instead, so this endpoint deletes the calling session and signs the user out. The new tests send JSON bodies and do not cover this request path.

### Issue 2
tests/e2e/Services/Account/AccountCustomClientTest.php:1819-1826
The new tests use an ordinary cookie or a JWT, but neither sends a fallback cookie or checks the changed `X-Fallback-Cookies` response header. A regression that clears the caller's fallback cookie while keeping its server-side session would pass both tests but sign out that client. An API-level fallback-cookie assertion would cover this observable behavior.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

The PR adds current=false to delete other account sessions while retaining the calling session, documents the option, and adds cookie and JWT end-to-end coverage.

  • The latest change rejects current=false when no calling session is available.
  • The cookie test now checks that the response does not clear fallback cookies.

Reviews (2) · Last reviewed commit: "review comments"

Comment thread app/controllers/api/account.php Resolved
Comment thread app/controllers/api/account.php Resolved
@Meldiron
Meldiron merged commit acb4a47 into appwrite:main Sep 29, 2026
51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants