mirror of
https://github.com/donpat1to/Schichtenplaner.git
synced 2025-11-30 22:45:46 +01:00
changed static password length statements 6 -> 8
This commit is contained in:
@@ -766,7 +766,7 @@ export const changePassword = async (req: AuthRequest, res: Response): Promise<v
|
||||
}
|
||||
|
||||
// Validate new password
|
||||
if (!newPassword || newPassword.length < 6) {
|
||||
if (!newPassword || newPassword.length < 8) {
|
||||
res.status(400).json({ error: 'New password must be at least 8 characters long' });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ function generateEmail(firstname: string, lastname: string): string {
|
||||
|
||||
const cleanFirstname = convertUmlauts(firstname).replace(/[^a-z0-9]/g, '');
|
||||
const cleanLastname = convertUmlauts(lastname).replace(/[^a-z0-9]/g, '');
|
||||
|
||||
|
||||
return `${cleanFirstname}.${cleanLastname}@sp.de`;
|
||||
}
|
||||
|
||||
@@ -31,15 +31,15 @@ export const checkSetupStatus = async (req: Request, res: Response): Promise<voi
|
||||
);
|
||||
|
||||
console.log('Admin exists check:', adminExists);
|
||||
|
||||
|
||||
const needsSetup = !adminExists || adminExists['COUNT(*)'] === 0;
|
||||
|
||||
|
||||
res.json({
|
||||
needsSetup: needsSetup
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error checking setup status:', error);
|
||||
res.status(500).json({
|
||||
res.status(500).json({
|
||||
error: 'Internal server error during setup check'
|
||||
});
|
||||
}
|
||||
@@ -75,8 +75,8 @@ export const setupAdmin = async (req: Request, res: Response): Promise<void> =>
|
||||
}
|
||||
|
||||
// Password length validation
|
||||
if (password.length < 6) {
|
||||
res.status(400).json({ error: 'Das Passwort muss mindestens 6 Zeichen lang sein' });
|
||||
if (password.length < 8) {
|
||||
res.status(400).json({ error: 'Das Passwort muss mindestens 8 Zeichen lang sein' });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -125,15 +125,15 @@ export const setupAdmin = async (req: Request, res: Response): Promise<void> =>
|
||||
} catch (dbError) {
|
||||
await db.run('ROLLBACK');
|
||||
console.error('❌ Database error during admin creation:', dbError);
|
||||
res.status(500).json({
|
||||
res.status(500).json({
|
||||
error: 'Fehler beim Erstellen des Admin-Accounts'
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('❌ Error in setup:', error);
|
||||
|
||||
|
||||
if (!res.headersSent) {
|
||||
res.status(500).json({
|
||||
res.status(500).json({
|
||||
error: 'Ein unerwarteter Fehler ist aufgetreten'
|
||||
});
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
### \[CREATE\] Employee
|
||||
* `firstname` 1-100 characters and must not be empty
|
||||
* `lastname` 1-100 characters and must not be empty
|
||||
* `password` must be at least 6 characters (in create mode)
|
||||
* `password` must be at least 8 characters (in create mode)
|
||||
* `employeeType` must be `manager`, `personell`, `apprentice`, or `guest`
|
||||
* `canWorkAlone` optional boolean
|
||||
* `isTrainee` optional boolean
|
||||
|
||||
@@ -14,7 +14,7 @@ function generateEmail(firstname: string, lastname: string): string {
|
||||
|
||||
const cleanFirstname = convertUmlauts(firstname).replace(/[^a-z0-9]/g, '');
|
||||
const cleanLastname = convertUmlauts(lastname).replace(/[^a-z0-9]/g, '');
|
||||
|
||||
|
||||
return `${cleanFirstname}.${cleanLastname}@sp.de`;
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ function generateEmail(firstname: string, lastname: string): string {
|
||||
export function validateEmployeeData(employee: CreateEmployeeRequest): string[] {
|
||||
const errors: string[] = [];
|
||||
|
||||
if (employee.password?.length < 6) {
|
||||
errors.push('Password must be at least 6 characters long');
|
||||
if (employee.password?.length < 8) {
|
||||
errors.push('Password must be at least 8 characters long');
|
||||
}
|
||||
|
||||
if (!employee.firstname?.trim() || employee.firstname.trim().length < 2) {
|
||||
@@ -72,16 +72,16 @@ export function generateEmployeeEmail(firstname: string, lastname: string): stri
|
||||
}
|
||||
|
||||
// UPDATED: Business logic helpers for new employee types
|
||||
export const isManager = (employee: Employee): boolean =>
|
||||
export const isManager = (employee: Employee): boolean =>
|
||||
employee.employeeType === 'manager';
|
||||
|
||||
export const isPersonell = (employee: Employee): boolean =>
|
||||
export const isPersonell = (employee: Employee): boolean =>
|
||||
employee.employeeType === 'personell';
|
||||
|
||||
export const isApprentice = (employee: Employee): boolean =>
|
||||
export const isApprentice = (employee: Employee): boolean =>
|
||||
employee.employeeType === 'apprentice';
|
||||
|
||||
export const isGuest = (employee: Employee): boolean =>
|
||||
export const isGuest = (employee: Employee): boolean =>
|
||||
employee.employeeType === 'guest';
|
||||
|
||||
export const isInternal = (employee: Employee): boolean =>
|
||||
@@ -91,24 +91,24 @@ export const isExternal = (employee: Employee): boolean =>
|
||||
employee.employeeType === 'guest';
|
||||
|
||||
// UPDATED: Trainee logic - now based on isTrainee field for personell type
|
||||
export const isTrainee = (employee: Employee): boolean =>
|
||||
export const isTrainee = (employee: Employee): boolean =>
|
||||
employee.employeeType === 'personell' && employee.isTrainee;
|
||||
|
||||
export const isExperienced = (employee: Employee): boolean =>
|
||||
export const isExperienced = (employee: Employee): boolean =>
|
||||
employee.employeeType === 'personell' && !employee.isTrainee;
|
||||
|
||||
// Role-based helpers
|
||||
export const isAdmin = (employee: Employee): boolean =>
|
||||
export const isAdmin = (employee: Employee): boolean =>
|
||||
employee.roles?.includes('admin') || false;
|
||||
|
||||
export const isMaintenance = (employee: Employee): boolean =>
|
||||
export const isMaintenance = (employee: Employee): boolean =>
|
||||
employee.roles?.includes('maintenance') || false;
|
||||
|
||||
export const isUser = (employee: Employee): boolean =>
|
||||
export const isUser = (employee: Employee): boolean =>
|
||||
employee.roles?.includes('user') || false;
|
||||
|
||||
// UPDATED: Work alone permission - managers and experienced personell can work alone
|
||||
export const canEmployeeWorkAlone = (employee: Employee): boolean =>
|
||||
export const canEmployeeWorkAlone = (employee: Employee): boolean =>
|
||||
employee.canWorkAlone && (isManager(employee) || isExperienced(employee));
|
||||
|
||||
// Helper for full name display
|
||||
|
||||
Reference in New Issue
Block a user