frontend changes with drop elements

This commit is contained in:
sriram
2026-08-18 18:39:20 +05:30
parent 39ae51e291
commit 8bb53d19dd
4 changed files with 10 additions and 636 deletions

View File

@@ -35,10 +35,9 @@ export function LoginPage() {
try {
const user = await login(username, password);
setLoading(false);
// Route by the role the SERVER assigned. Only `admin` can sign in now,
// but a token minted for any other role still lands somewhere valid.
if (user.role === 'admin') navigate('/admin');
else navigate('/user');
// Only `admin` can sign in, and every route is admin-only, so there is
// one destination. Sending a non-admin to /login instead would loop.
navigate(user.role === 'admin' ? '/admin' : '/login');
} catch (err) {
setLoading(false);
// Surface the server's own message: it distinguishes bad credentials