Code quality improvements from code review

- Add admin-only authorization for company and projects CRUD operations
- Create requireAccountId middleware to eliminate code duplication
- Standardize error handling (use next(error) consistently)
- Change error messages to Slovak language

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
richardtekula
2025-12-05 11:03:32 +01:00
parent 03b7a215bb
commit 6f4a31e9de
19 changed files with 186 additions and 191 deletions

View File

@@ -17,7 +17,7 @@ export const getEmailAccounts = async (req, res, next) => {
data: accounts,
});
} catch (error) {
return next(error);
next(error);
}
};
@@ -37,7 +37,7 @@ export const getEmailAccount = async (req, res, next) => {
data: account,
});
} catch (error) {
return next(error);
next(error);
}
};
@@ -67,7 +67,7 @@ export const createEmailAccount = async (req, res, next) => {
message: 'Email účet úspešne pripojený',
});
} catch (error) {
return next(error);
next(error);
}
};
@@ -93,7 +93,7 @@ export const updateEmailAccountPassword = async (req, res, next) => {
message: 'Heslo k emailovému účtu bolo aktualizované',
});
} catch (error) {
return next(error);
next(error);
}
};
@@ -119,7 +119,7 @@ export const toggleEmailAccountStatus = async (req, res, next) => {
message: `Email účet ${isActive ? 'aktivovaný' : 'deaktivovaný'}`,
});
} catch (error) {
return next(error);
next(error);
}
};
@@ -140,7 +140,7 @@ export const setPrimaryEmailAccount = async (req, res, next) => {
message: 'Primárny email účet bol nastavený',
});
} catch (error) {
return next(error);
next(error);
}
};
@@ -161,6 +161,6 @@ export const deleteEmailAccount = async (req, res, next) => {
message: result.message,
});
} catch (error) {
return next(error);
next(error);
}
};