fix(admin): make login endpoint return HTTP 200 with explicit error message for debugging
Some checks failed
Deploy RIT Freshers Hub to VPS / Deploy to Live VPS (push) Has been cancelled

This commit is contained in:
Shanmuga Krishnan S M
2026-08-07 14:28:59 +05:30
parent 9357c18d69
commit 2f978ab244
2 changed files with 26 additions and 11 deletions

View File

@@ -46,9 +46,13 @@ export default function AdminDashboard() {
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ username, password }),
})
.then((res) => {
if (!res.ok) throw new Error('Invalid username or password');
return res.json();
.then(async (res) => {
try {
const data = await res.json();
return data;
} catch (e) {
return { success: false, message: `Server returned HTTP ${res.status}` };
}
})
.then((data) => {
if (data.success) {
@@ -56,7 +60,7 @@ export default function AdminDashboard() {
setIsLoggedIn(true);
fetchRecipients();
} else {
setLoginError(data.message || 'Login failed');
setLoginError(data.message || 'Invalid username or password');
}
})
.catch((err) => {