feat(auth): auto-redirect after authentication#212
Merged
zainfathoni merged 4 commits intostagingfrom Feb 1, 2026
Merged
Conversation
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>
- 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>
- 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>
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'
zainfathoni
added a commit
that referenced
this pull request
Feb 10, 2026
* 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 * 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 * 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 * 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: Zain Fathoni <me@zainf.dev> Co-authored-by: Amp <amp@ampcode.com>
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.
Summary
Implements auto-redirect after authentication and consistent permission redirects for the dashboard.
Changes
Auto-redirect after authentication (rb-logic.1)
redirectTofrom URL params, store in session, preserve through magic link flowredirectTofrom session and redirect there after successful authPermission redirects (rb-logic.2)
dashboard.transactions.$transactionId.$actionloader/dashboardinstead of inconsistent pathsFlow
/dashboard/courses(protected)requireUserredirects to/login?redirectTo=/dashboard/coursesredirectToin session and sends magic link/magicreads session and redirects to/dashboard/courses/dashboardTests
Reference
Based on: zainfathoni/remix-jokes@a931d94
Closes rb-logic.1, rb-logic.2