feat: Add manager permissions management component and related functionality

- Implemented ManagerPermissions.vue for managing manager accounts, including adding, editing, and deleting managers.
- Integrated a modal for adding new managers with form validation.
- Added functionality to fetch, display, and paginate manager data.
- Created a toast notification system for user feedback on actions.
- Developed a reusable Toast component for displaying notifications.
- Introduced a useToast composable for managing toast notifications.
- Added permissions management for managers, including fetching and saving permissions.
- Implemented password change functionality for managers.
- Enhanced error handling and user feedback throughout the manager management process.
- Added root CA and private key files for secure communication.
This commit is contained in:
sudomarcma
2025-07-18 15:56:55 +08:00
parent 601b32a7c8
commit 7769a89708
25 changed files with 1708 additions and 467 deletions
+9 -2
View File
@@ -26,11 +26,18 @@ export default function(db) {
router.post('/auth/login', async (req, res) => {
const { username, password, deviceUuid } = req.body;
const [rows] = await db.execute('SELECT id, role, password_hash FROM workers WHERE username = ?', [username]);
const [rows] = await db.execute('SELECT id, role, password_hash, status FROM workers WHERE username = ?', [username]);
if (rows.length === 0) {
return res.status(401).json({ message: 'Invalid credentials' });
}
const user = rows[0];
// Check if the worker's status is 'active'
if (user.role === 'worker' && user.status !== 'active') {
// Return the same message as invalid credentials to avoid leaking information
return res.status(401).json({ message: 'Invalid credentials' });
}
const passwordMatch = await bcrypt.compare(password, user.password_hash);
if (!passwordMatch) {
return res.status(401).json({ message: 'Invalid credentials' });
@@ -53,7 +60,7 @@ export default function(db) {
if (err) {
return res.status(403).json({ message: 'Invalid or expired token' });
}
req.user = user;
req.user = { ...user, id: user.userId }; // Correctly map userId to id
next();
});
} else {