Uh oh!
There was an error while loading. Please reload this page.
fix: user-redirection-when-vote - #726
Conversation
📝 WalkthroughWalkthroughCaptures Changes
Sequence Diagram(s)sequenceDiagram
participant Browser as Browser (Client)
participant Router as Router
participant AuthAPI as Auth API (POST /login)
participant SSE as SSE Server
participant Storage as sessionStorage
Browser->>AuthAPI: POST /login (auto-login)
AuthAPI-->>Browser: 200 + auth token
Browser->>Storage: read "postLoginRedirect" or use redirectTo or "/"
Browser->>Storage: remove "postLoginRedirect"
Browser->>Router: navigate to resolved redirect
Note right of Browser: SSE-based flow
Browser->>SSE: open EventSource
SSE-->>Browser: onmessage (token OR version_mismatch)
alt token received
Browser->>AuthAPI: signInWithCustomToken(token)
AuthAPI-->>Browser: auth success
Browser->>Storage: read "postLoginRedirect" or use redirectTo or "/"
Browser->>Storage: remove "postLoginRedirect"
Browser->>Router: navigate to resolved redirect
else version_mismatch
Browser->>Browser: handle version mismatch (show error/notify)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Fix all issues with AI agents
In `@infrastructure/eid-wallet/src/routes/`(app)/scan-qr/+page.svelte:
- Around line 95-100: Remove the debug $effect block that logs
selectedBlindVoteOption to the console; locate the reactive $effect referencing
$selectedBlindVoteOption and delete the entire block (or replace it with a
non-logging dev-only guard around the effect if runtime debugging is needed),
ensuring there are no remaining console.log statements related to
selectedBlindVoteOption.
In `@platforms/eVoting/src/app/`(auth)/login/page.tsx:
- Line 189: Update the typo in the login page JSX where the span reads "Click
the button below using you" to "Click the button below using your"; locate the
span in the login page component (page.tsx) and correct the string literal so
wording matches the desktop version.
- Around line 44-47: The redirect check currently accepts values that start with
"/" which still allows protocol-relative URLs like "//evil.com"; update the
validation where redirect is handled (the conditional using
redirect.startsWith("/") and the subsequent setRedirectTo and
sessionStorage.setItem calls) to explicitly reject protocol-relative paths by
ensuring the second character is not "/" (e.g., require redirect.startsWith("/")
&& redirect[1] !== "/") or validate that redirect is a safe local pathname
(parse and confirm it has no host/authority component) before calling
setRedirectTo and sessionStorage.setItem("postLoginRedirect", ...).
- Around line 137-141: The SSE handler uses the redirectTo state but the
useEffect that registers it does not include redirectTo in its dependency array,
risking a stale closure; update the useEffect that sets up the SSE handler (the
effect that reads sessionStorage.getItem("postLoginRedirect") and calls
window.location.href = redirect) to include redirectTo in its dependency array
so the handler always captures the latest redirectTo value, and ensure any
cleanup/registration logic (the SSE subscription) still runs correctly when
redirectTo changes.
🧹 Nitpick comments (2)
platforms/eVoting/src/app/(auth)/login/page.tsx (2)
44-47: Fix inconsistent indentation.The code block has inconsistent indentation which affects readability. The
ifblock body should be indented consistently with the surrounding code.🔧 Proposed fix
if (redirect && redirect.startsWith("/")) { - setRedirectTo(redirect);- sessionStorage.setItem("postLoginRedirect", redirect);- }+ setRedirectTo(redirect);+ sessionStorage.setItem("postLoginRedirect", redirect);+ }
95-99: Fix inconsistent indentation in redirect logic.Similar to the earlier block, this code has inconsistent indentation that should be corrected for readability and maintainability.
🔧 Proposed fix
const redirect = - sessionStorage.getItem("postLoginRedirect") || redirectTo || "/";--sessionStorage.removeItem("postLoginRedirect");-window.location.href = redirect;+ sessionStorage.getItem("postLoginRedirect") || redirectTo || "/";+ sessionStorage.removeItem("postLoginRedirect");+ window.location.href = redirect;
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
platforms/eVoting/src/app/(auth)/login/page.tsx (1)
24-47: Persist redirect before early return to avoid losing it in auto-login flows.
If the login page is first opened withename/session/signature(e.g., a new tab on mobile), the redirect param is ignored because the effect returns before saving it. That can fall back to/even when a redirect was provided.🐛 Proposed fix
- if (ename && session && signature) {- // Clean up URL- window.history.replaceState({}, '', window.location.pathname);-- // Auto-submit login- handleAutoLogin(ename, session, signature, appVersion || '0.4.0');- return;- }-- if (redirect && redirect.startsWith("/") && !redirect.startsWith("//")) {- setRedirectTo(redirect);- sessionStorage.setItem("postLoginRedirect", redirect);- }+ if (redirect && redirect.startsWith("/") && !redirect.startsWith("//")) {+ setRedirectTo(redirect);+ sessionStorage.setItem("postLoginRedirect", redirect);+ }++ if (ename && session && signature) {+ // Clean up URL+ window.history.replaceState({}, '', window.location.pathname);++ // Auto-submit login+ handleAutoLogin(ename, session, signature, appVersion || '0.4.0');+ return;+ }
🤖 Fix all issues with AI agents
In `@infrastructure/control-panel/src/lib/ui/Table/Table.svelte`:
- Line 377: The snippet parameter for BodyCell is using the bare Record type
causing a TS error; change the parameter type for data in the BodyCell snippet
to be Record<string, TableCell<T>> (matching the component's generic T and the
TableCell type) so the snippet declaration reads BodyCell(data: Record<string,
TableCell<T>>, field: string, i: number) and aligns with the component generics
and usages of TableCell<T>.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@platforms/dreamSync/client/src/components/auth-modal.tsx`:
- Around line 41-43: The useForm call for loginForm is using an unnecessary cast
that disables type inference; remove the "as any" cast on zodResolver so
zodResolver(loginSchema) is passed directly to useForm (loginForm) and let the
resolver infer types from loginSchema; update the same pattern where zodResolver
is used for other forms to drop the "as any" casts.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@docker-compose.core.yml`:
- Around line 74-96: Replace the hardcoded default values for the registry
service environment variables so the compose file requires values from .env:
remove the default fallbacks from NODE_ENV, DATABASE_URL, REGISTRY_SHARED_SECRET
and PUBLIC_REGISTRY_URL (use ${NODE_ENV}, ${REGISTRY_DATABASE_URL},
${REGISTRY_SHARED_SECRET}, ${PUBLIC_REGISTRY_URL} respectively), and mirror the
same change for the evault-core service; then update .env.example to document
DATABASE_URL and REGISTRY_SHARED_SECRET (and PUBLIC_REGISTRY_URL) as required
secrets/connection strings so Docker Compose fails if they are not provided.
- Around line 36-72: Remove the hard-coded password from the neo4j service: stop
setting NEO4J_AUTH=neo4j/passkipooski in the environment and instead require a
NEO4J_PASSWORD environment variable (provided via a .env file or env_file kept
out of VCS) and set NEO4J_AUTH from that secret outside the repository; then
update the neo4j healthcheck to perform container-side expansion by invoking a
shell (e.g., change the healthcheck test to use "bash -lc" and reference
"$NEO4J_PASSWORD" inside that command so the password is expanded inside the
container when running cypher-shell) — modify the neo4j service environment and
the healthcheck test (referencing the neo4j service, NEO4J_AUTH/NEO4J_PASSWORD,
and the healthcheck test block) accordingly.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
coodos
commented
Jan 29, 2026
approved at the condition you fix code rabbit suggestions |

Description of change
Fixed the issue of redirection to home page instead of to the vote id after user successfully login to evoting.
Issue Number
closes#703
Type of change
How the change has been tested
Manual
Change checklist
Summary by CodeRabbit
New Features
Bug Fixes
Chores
✏️ Tip: You can customize this high-level summary in your review settings.