From 5bf5c6afff7b37295a6a1826be666256eb43b346 Mon Sep 17 00:00:00 2001 From: gourav Date: Fri, 30 Jan 2026 15:28:53 +0530 Subject: [PATCH 1/2] fix: user-redirection-when-voting --- .../eVoting/src/app/(auth)/login/page.tsx | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/platforms/eVoting/src/app/(auth)/login/page.tsx b/platforms/eVoting/src/app/(auth)/login/page.tsx index 2402579c..1d17687b 100644 --- a/platforms/eVoting/src/app/(auth)/login/page.tsx +++ b/platforms/eVoting/src/app/(auth)/login/page.tsx @@ -14,6 +14,8 @@ export default function LoginPage() { const [errorMessage, setErrorMessage] = useState(null); const [isLoading, setIsLoading] = useState(true); const [isMobile, setIsMobile] = useState(false); + const [redirectTo, setRedirectTo] = useState("/"); + useEffect(() => { setIsMobile(isMobileDevice()); @@ -24,6 +26,7 @@ export default function LoginPage() { if (typeof window === 'undefined') return; const params = new URLSearchParams(window.location.search); + const redirect = params.get("redirect"); const ename = params.get('ename'); const session = params.get('session'); const signature = params.get('signature'); @@ -38,6 +41,11 @@ export default function LoginPage() { return; } + if (redirect && redirect.startsWith("/") && !redirect.startsWith("//")) { + setRedirectTo(redirect); + sessionStorage.setItem("postLoginRedirect", redirect); + } + // If no query params, proceed with normal flow const fetchQRCode = async () => { try { @@ -84,7 +92,11 @@ export default function LoginPage() { if (data.token && data.user) { setAuthToken(data.token); setAuthId(data.user.id); - window.location.href = "/"; + const redirect = + sessionStorage.getItem("postLoginRedirect") || redirectTo || "/"; + +sessionStorage.removeItem("postLoginRedirect"); +window.location.href = redirect; } } else { const errorData = await response.json(); @@ -122,7 +134,11 @@ export default function LoginPage() { if (data.token && data.user) { setAuthToken(data.token); setAuthId(data.user.id); - window.location.href = "/"; + const redirect = + sessionStorage.getItem("postLoginRedirect") || redirectTo || "/"; + +sessionStorage.removeItem("postLoginRedirect"); +window.location.href = redirect; } } catch (error) { console.error("Error parsing SSE data:", error); @@ -134,7 +150,7 @@ export default function LoginPage() { }; return () => eventSource.close(); - }, [sessionId, login]); + }, [sessionId, login, redirectTo]); const getAppStoreLink = () => { if (typeof navigator === 'undefined') return "https://play.google.com/store/apps/details?id=foundation.metastate.eid_wallet"; @@ -170,7 +186,7 @@ export default function LoginPage() {
{isMobile ? ( <> - Click the button below using your + Click the button below using you eID App to login @@ -250,4 +266,4 @@ export default function LoginPage() {
); -} +} \ No newline at end of file From 6b50fb3d6773e046a807e0844ec51303d2793b95 Mon Sep 17 00:00:00 2001 From: Merul Dhiman Date: Fri, 30 Jan 2026 18:32:46 +0530 Subject: [PATCH 2/2] chore: format --- .../eVoting/src/app/(auth)/login/page.tsx | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/platforms/eVoting/src/app/(auth)/login/page.tsx b/platforms/eVoting/src/app/(auth)/login/page.tsx index 1d17687b..57463045 100644 --- a/platforms/eVoting/src/app/(auth)/login/page.tsx +++ b/platforms/eVoting/src/app/(auth)/login/page.tsx @@ -35,16 +35,16 @@ export default function LoginPage() { 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); - } + setRedirectTo(redirect); + sessionStorage.setItem("postLoginRedirect", redirect); + } // If no query params, proceed with normal flow const fetchQRCode = async () => { @@ -93,10 +93,10 @@ export default function LoginPage() { setAuthToken(data.token); setAuthId(data.user.id); const redirect = - sessionStorage.getItem("postLoginRedirect") || redirectTo || "/"; + sessionStorage.getItem("postLoginRedirect") || redirectTo || "/"; -sessionStorage.removeItem("postLoginRedirect"); -window.location.href = redirect; + sessionStorage.removeItem("postLoginRedirect"); + window.location.href = redirect; } } else { const errorData = await response.json(); @@ -122,7 +122,7 @@ window.location.href = redirect; eventSource.onmessage = (event) => { try { const data = JSON.parse(event.data); - + // Check for error messages (version mismatch) if (data.error && data.type === 'version_mismatch') { setErrorMessage(data.message || 'Your eID Wallet app version is outdated. Please update to continue.'); @@ -135,10 +135,10 @@ window.location.href = redirect; setAuthToken(data.token); setAuthId(data.user.id); const redirect = - sessionStorage.getItem("postLoginRedirect") || redirectTo || "/"; + sessionStorage.getItem("postLoginRedirect") || redirectTo || "/"; -sessionStorage.removeItem("postLoginRedirect"); -window.location.href = redirect; + sessionStorage.removeItem("postLoginRedirect"); + window.location.href = redirect; } } catch (error) { console.error("Error parsing SSE data:", error); @@ -200,7 +200,7 @@ window.location.href = redirect; {error &&
{error}
} - + {errorMessage && (

Authentication Error

@@ -266,4 +266,4 @@ window.location.href = redirect;
); -} \ No newline at end of file +}