feat(backend): GET /devices — list the caller's own devices#207
Open
Olorunfemi20 wants to merge 2 commits into
Open
feat(backend): GET /devices — list the caller's own devices#207Olorunfemi20 wants to merge 2 commits into
Olorunfemi20 wants to merge 2 commits into
Conversation
|
@Olorunfemi20 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #156
Summary
Adds a
GET /devicesendpoint that returns the authenticated user's registered devices, backed by theuser_devicestable. The list includes revoked devices (for device history) and flags the device bound to the caller's session.Changes
devicesRouter(src/routes/devices.ts) exposingGET /devices, mounted at/devicesinapp.tsand guarded byrequireAuth.[{ id, deviceId, deviceName, platform, lastSeenAt, createdAt, revokedAt, current }].WHERE user_id = <caller>).revoked_at IS NULL), then most recently registered; revoked devices are included withrevokedAtset.currentis true for the device whosedeviceIdmatches the caller's JWT.JwtPayloadwith an optionaldeviceIdso the session can be associated with a registered device. The field is optional and backward compatible with existing tokens; when absent, every device is reported ascurrent: false.src/__tests__/devices.test.tscovering auth, user scoping, active-first ordering with revoked devices,currentflagging (with and without adeviceIdclaim), response shape, and the database-failure path.Acceptance criteria
currentcorrectly flags the requesting device.Notes
This builds on the
user_devicesschema (#153). Population ofdeviceIdin issued tokens belongs to the device registration/login flow and is intentionally out of scope here; the endpoint degrades gracefully until then.