feat(auth): enhance login flow with notifications and path normalization
CI / Test (1.22) (push) Failing after -30m33s
CI / Test (1.23) (push) Failing after -30m32s
CI / Lint (push) Failing after -30m39s
CI / Build (push) Failing after -30m35s

- add success notification on successful login
- show error notification with detailed message on login failure
- normalize API paths to prevent double slashes and trailing slashes
- redirect to login page only if not on login request or page
This commit is contained in:
2026-03-05 01:03:50 +02:00
parent 1490e0b596
commit 271a0603b8
10 changed files with 230 additions and 29 deletions
+18 -3
View File
@@ -13,6 +13,7 @@ import {
Center,
Box
} from '@mantine/core';
import { notifications } from '@mantine/notifications';
import { IconAlertCircle, IconBrandWhatsapp } from '@tabler/icons-react';
import { useAuthStore } from '../stores/authStore';
@@ -28,10 +29,24 @@ export default function LoginPage() {
try {
await login(username, password);
notifications.show({
title: 'Login successful',
message: 'Welcome back!',
color: 'green',
});
navigate('/');
} catch (err) {
// Error is handled in the store
console.error('Login failed:', err);
} catch (err: any) {
const responseData = err?.response?.data;
const notificationMessage =
responseData?.message ||
(typeof responseData === 'string' ? responseData.trim() : '') ||
'Invalid username or password';
notifications.show({
title: 'Login failed',
message: notificationMessage,
color: 'red',
});
}
};