fix: redirect logged-in users from login page to dashboard#4099
Open
sputnik-mac wants to merge 1 commit intoumami-software:masterfrom
Open
fix: redirect logged-in users from login page to dashboard#4099sputnik-mac wants to merge 1 commit intoumami-software:masterfrom
sputnik-mac wants to merge 1 commit intoumami-software:masterfrom
Conversation
When a user with a valid session visits /login, they now get redirected to the dashboard (/) instead of seeing the login form. Uses the existing useLoginQuery hook to verify auth state server-side before rendering. Fixes umami-software#4094
|
@sputnik-mac is attempting to deploy a commit to the Umami Software Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
Greptile SummaryThis PR fixes a UX issue where already-authenticated users navigating to
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant U as User (Browser)
participant LP as LoginPage
participant LQ as useLoginQuery
participant API as POST /auth/verify
participant Store as App Store
U->>LP: Navigate to /login
LP->>LQ: Call useLoginQuery()
LQ->>Store: Read user from app store
alt User already in store
Store-->>LQ: user (truthy)
LQ-->>LP: { user, isLoading: false }
LP->>U: Render <Loading />
LP->>U: router.replace('/') [useEffect]
else User NOT in store
Store-->>LQ: null
LQ->>API: POST /auth/verify (token from cookie/header)
LP->>U: Render <Loading /> (isLoading: true)
alt Token valid
API-->>LQ: user data
LQ->>Store: setUser(data)
LQ-->>LP: { user, isLoading: false }
LP->>U: Render <Loading /> (user truthy)
LP->>U: router.replace('/') [useEffect]
else Token invalid / no token
API-->>LQ: 401 error
LQ-->>LP: { user: null, isLoading: false }
LP->>U: Render <LoginForm />
end
end
Reviews (1): Last reviewed commit: "fix: redirect logged-in users from login..." | Re-trigger Greptile |
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
When a user with an active session navigates to
/login(e.g., by clicking "Get Started" on the homepage), they currently see the login form even though they're already authenticated. This is confusing since their session is valid.Changes
src/app/login/LoginPage.tsx: Added auth check using the existinguseLoginQueryhook. If the user is already logged in, they are redirected to/(which routes to their dashboard). While loading/redirecting, a loading indicator is shown instead of the login form.How it works
useLoginQuerycallsPOST /auth/verify— this validates the token server-siderouter.replace('/')redirects to dashboardFixes #4094