From 39fce8d4369e0e368f65838a898bb64b59996b87 Mon Sep 17 00:00:00 2001 From: fdai7207 <haytham.daoula@informatik.hs-fulda.de> Date: Sun, 5 Feb 2023 19:29:54 +0100 Subject: [PATCH] implement the isValidPassword() function in the getNewEmployeeCredentials() function in order to check the validity of the entered password. --- src/createEmployeeAccount.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/createEmployeeAccount.c b/src/createEmployeeAccount.c index 3951a63..37b8452 100644 --- a/src/createEmployeeAccount.c +++ b/src/createEmployeeAccount.c @@ -105,14 +105,19 @@ void getNewEmployeeCredentials() employeePassword[strlen(employeePassword)] = '\0'; - if(isValidEmployeeID(employeeId,employeeIdLength)) + if(isValidEmployeeID(employeeId,employeeIdLength) && isValidPassword(employeePassword,minimumPasswordLength)) { createNewEmployee(employeeId,employeePassword) ? printf("\n\n Account created successfully !\n\n") : printf("\n\n Could not create the Account please contact an employee of clearance 1 !\n\n"); } + else if(isValidEmployeeID(employeeId,employeeIdLength) && !isValidPassword(employeePassword,minimumPasswordLength)) + { + printf("Error : the entered password should be at least 5 characters long and should contain at least 1 digit, 1 alphabet and 1 punctuation character!"); + } + else { - printf("Error : the entered ID either contains space or exceeds the maximum of 20 characters!"); + printf("Error : the entered ID should contain a maximum of 20 letters"); } }