frontend changes with drop elements
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user