Skip to content

Commit 73a4e58

Browse files
committed
fix: add error message to evoting page
1 parent 6148a99 commit 73a4e58

File tree

1 file changed

+26
-5
lines changed
  • platforms/eVoting/src/app/(auth)/login

1 file changed

+26
-5
lines changed

platforms/eVoting/src/app/(auth)/login/page.tsx

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export default function LoginPage() {
1111
const [qrData, setQrData] = useState<string | null>(null);
1212
const [sessionId, setSessionId] = useState<string | null>(null);
1313
const [error, setError] = useState<string | null>(null);
14+
const [errorMessage, setErrorMessage] = useState<string | null>(null);
1415
const [isLoading, setIsLoading] = useState(true);
1516
const [isMobile, setIsMobile] = useState(false);
1617

@@ -51,11 +52,24 @@ export default function LoginPage() {
5152
);
5253

5354
eventSource.onmessage = (event) => {
54-
const data = JSON.parse(event.data);
55-
if (data.token && data.user) {
56-
setAuthToken(data.token);
57-
setAuthId(data.user.id);
58-
window.location.href = "/";
55+
try {
56+
const data = JSON.parse(event.data);
57+
58+
// Check for error messages (version mismatch)
59+
if (data.error && data.type === 'version_mismatch') {
60+
setErrorMessage(data.message || 'Your eID Wallet app version is outdated. Please update to continue.');
61+
eventSource.close();
62+
return;
63+
}
64+
65+
// Handle successful authentication
66+
if (data.token && data.user) {
67+
setAuthToken(data.token);
68+
setAuthId(data.user.id);
69+
window.location.href = "/";
70+
}
71+
} catch (error) {
72+
console.error("Error parsing SSE data:", error);
5973
}
6074
};
6175

@@ -114,6 +128,13 @@ export default function LoginPage() {
114128
</div>
115129

116130
{error && <div className="w-full text-red-500">{error}</div>}
131+
132+
{errorMessage && (
133+
<div className="w-full mb-4 p-4 bg-red-100 border border-red-400 text-red-700 rounded-lg">
134+
<p className="font-semibold">Authentication Error</p>
135+
<p className="text-sm">{errorMessage}</p>
136+
</div>
137+
)}
117138

118139
{isLoading ? (
119140
<div className="w-48 h-48 bg-gray-100 rounded-lg flex items-center justify-center">

0 commit comments

Comments
 (0)