Skip to content

Redirect to the page the UI has for an adopted device - #99

Merged
adamshiervani merged 1 commit into
devfrom
fix/already-adopted-redirect
Dec 4, 2026
Merged

adamshiervani merged 1 commit into
devfrom
fix/already-adopted-redirect

Conversation

@adamshiervani

@adamshiervani adamshiervani commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Problem

A user signs in to adopt a device that another account has registered. The user lands on https://app.jetkvm.com/already-adopted and sees the "Not found" page. The user gets no explanation of why the adoption failed.

Cause

The sign-in callback in src/oidc.ts redirects this case to /already-adopted. The UI serves the "Device Already Registered" page at /devices/already-adopted. Both paths date from the first release of each repo, so this redirect has never reached the page.

Fix

The callback now redirects to /devices/already-adopted. The UI path follows its other devices/* routes, so the redirect is the side to change. The fix needs no UI release.

Testing

I loaded both paths on app.jetkvm.com (UI 0.5.11) in headless Chromium:

Path Page shown
/already-adopted Not found
/devices/already-adopted Device Already Registered

I did not exercise the sign-in callback itself, because that needs a Google session and a device registered to a second account. The change adds no test.


Note

Low Risk
Single redirect URL change on an error path; no auth, data, or adoption logic changes.

Overview
When Google sign-in runs during device adoption and the device is already registered to another account, the OIDC callback used to send users to /already-adopted, which the app does not serve (404). The redirect is now /devices/already-adopted, matching the existing UI route that shows the “Device Already Registered” message.

No UI or other backend changes are required for this behavior fix.

Reviewed by Cursor Bugbot for commit c47eec9. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • Bug Fixes
    • Corrected the destination shown when a device has already been adopted by another user. The redirect now leads to the device-specific already-adopted page, so users see the appropriate information for this situation.

The sign-in callback sent a user who adopts a device that another account
owns to /already-adopted. The UI serves that page at
/devices/already-adopted, so the user got the not-found page.
@coderabbitai

coderabbitai Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes: Device adoption redirect

Layer / File(s) Summary
Update adopted-device redirect
src/oidc.ts
The callback redirect changes from /already-adopted to /devices/already-adopted when another user has adopted the device.

Change: Bug fix

Merge Risk: Minimal · up to c47ee

This fixes the redirect so users whose device is already registered to another account land on the "Device Already Registered" page instead of a "Not found" page. No concrete merge risk is identified.

Security architecture risk: Minimal · up to c47ee

JetKVM now sends users to the existing “Device Already Registered” page when they try to adopt a device registered to another account. The backend still blocks adoption under the same conditions and does not transfer ownership or issue a device token on this path.

Security review details

Security Blast Radius

  • observed — The change reaches browsers whose adoption attempts enter the existing other-owner branch. It adds no access to the registered device, its owner's data, or device credentials.

Trust Boundaries and Controls

  • observed — A device identifier supplied at sign-in influences which stored owner is checked, but it does not set the redirect destination. The callback uses the authenticated Google subject for the owner comparison, applies the existing email allowlist when configured, and ignores the caller-supplied return URL on this rejection branch.

Dependencies

  • inferred — The improved rejection message depends on the UI served at APP_HOSTNAME providing /devices/already-adopted. The author observed that route on app.jetkvm.com with UI 0.5.11; that route check did not exercise the authenticated redirect end to end.

Data and control flow

  • observed — The callback still verifies session state, exchanges the Google authorization code, checks the email against the identity policy, and upserts the signed-in user before looking up the device owner. A different owner triggers the redirect before temporary token generation or device upsert.

Resilience and Maintainability Implications

  • inferred — The new page explains the rejection; it does not complete or recover adoption. If the browser cannot load that page, the user may still miss the explanation, but the callback has already returned without changing device ownership or issuing a temporary device token.

Rollout and rollback

  • inferred — No coordinated UI release is indicated for the reported production UI. Reverting the backend change restores the old redirect that the author reports showed Not Found; it does not change who can permit adoption or require an operator to repair device state.
Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a3cc8d4b-ad8d-44c7-aefe-ca7254aceee6
Commits

Reviewing files that changed from the base of the PR and between c2c2107 and c47eec9.

Files selected for processing: 1

  • src/oidc.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.

@adamshiervani
adamshiervani merged commit 50376a0 into dev Dec 4, 2026
4 checks passed
@adamshiervani
adamshiervani deleted the fix/already-adopted-redirect branch December 4, 2026 15:37
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.

1 participant