Skip to content

Merge staging: Auto-redirect after authentication#222

Merged
zainfathoni merged 1 commit intomainfrom
staging
Feb 10, 2026
Merged

Merge staging: Auto-redirect after authentication#222
zainfathoni merged 1 commit intomainfrom
staging

Conversation

@wheeljackz
Copy link
Copy Markdown
Collaborator

@wheeljackz wheeljackz commented Feb 10, 2026

Summary

Merges staging branch containing authentication improvements and permission fixes.

Changes from PR #212

Auto-redirect after authentication

  • login.tsx: Read redirectTo from URL params, store in session, preserve through magic link flow
  • magic.tsx: Read redirectTo from session and redirect there after successful auth

Permission redirects

  • Add missing permission check in dashboard.transactions.$transactionId.$action loader
  • Standardize all permission redirects to /dashboard instead of inconsistent paths

Flow

  1. User visits /dashboard/courses (protected)
  2. requireUser redirects to /login?redirectTo=/dashboard/courses
  3. Login page stores redirectTo in session and sends magic link
  4. User clicks magic link → /magic reads session and redirects to /dashboard/courses
  5. If user lacks permission for a route, they're redirected to /dashboard

Tests included

  • Unit tests for redirect URL construction and preservation
  • Unit tests for permission functions
  • E2E tests for unauthenticated/authenticated redirect flows
  • E2E tests for permission redirect behavior

Previous PR: #212 (feat(auth): auto-redirect after authentication)

* feat(auth): auto-redirect after authentication

When a user tries to access a protected route without being authenticated,
the original URL is saved in session and they are redirected back after
successful magic link login.

Closes rb-logic.1

Amp-Thread-ID: https://ampcode.com/threads/T-019c17af-6967-74be-8e42-6191059b8d63
Co-authored-by: Amp <amp@ampcode.com>

* test(auth): add unit and e2e tests for auto-redirect

- Unit tests for redirect URL construction and preservation
- E2E tests for unauthenticated redirect flow and authenticated redirect

Amp-Thread-ID: https://ampcode.com/threads/T-019c17af-6967-74be-8e42-6191059b8d63
Co-authored-by: Amp <amp@ampcode.com>

* feat(auth): redirect to dashboard for insufficient permissions

- Add permission check in dashboard.transactions.$transactionId.$action loader
- Standardize all permission redirects to /dashboard instead of various paths
- Add comprehensive unit tests for permission functions
- Add E2E tests for permission redirect behavior

Closes rb-logic.2

Amp-Thread-ID: https://ampcode.com/threads/T-019c17de-be40-76a8-a962-78347f08fdda
Co-authored-by: Amp <amp@ampcode.com>

* fix(e2e): add admin fixture to global setup

The permission-redirect.spec.ts tests use authFixtures.admin,
but the global setup was not generating admin.local.json.

This caused all Admin role tests to fail in CI with:
'ENOENT: no such file or directory, open e2e/fixtures/auth/admin.local.json'

---------

Co-authored-by: Amp <amp@ampcode.com>
Copy link
Copy Markdown
Owner

@zainfathoni zainfathoni left a comment

Choose a reason for hiding this comment

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

LGTM - staging changes look safe. CI passed.

@zainfathoni zainfathoni changed the title Merge staging to main Merge staging: Auto-redirect after authentication Feb 10, 2026
@zainfathoni zainfathoni merged commit 2bfbac9 into main Feb 10, 2026
13 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