Browse Source

implement the verifyPassword() function in the getNewEmployeeCredentials() so that the validity of the password can be checked twice.

remotes/origin/feature/employees-infos-access
fdai7207 2 years ago
parent
commit
cd4fb8fb7d
  1. 42
      src/createEmployeeAccount.c
  2. 5
      src/employeesCredentialsList.txt

42
src/createEmployeeAccount.c

@ -97,18 +97,18 @@ bool createNewEmployee(char* employeeId, char* employeePassword)
void getNewEmployeeCredentials()
{
const int employeeIdLength = 21;
char employeeId[employeeIdLength];
const int Length = 21;
char employeeId[Length];
const int minimumPasswordLength = 5;
char employeePassword[minimumPasswordLength];
char employeePassword[Length];
char passwordVerfication[Length];
printf("please enter your wished Id :\n");
/*Added the regular expression [^\n] so that the string keep on getting read until a newline '\n' is found*/
scanf(" %[^\n]s",employeeId);
employeeId[employeeIdLength] = '\0';
employeeId[Length] = '\0';
printf("\nplease enter your wished Password :\n");
@ -116,20 +116,34 @@ void getNewEmployeeCredentials()
employeePassword[strlen(employeePassword)] = '\0';
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");
}
printf("\nplease confirm your Password :\n");
scanf("%s",passwordVerfication);
passwordVerfication[strlen(employeePassword)] = '\0';
else if(isValidEmployeeID(employeeId,employeeIdLength) && !isValidPassword(employeePassword,minimumPasswordLength))
if(verifyPassword(passwordVerfication,employeePassword))
{
printf("Error : the entered password should be at least 5 characters long and should contain at least 1 digit, 1 alphabet and 1 symbol!");
}
if(isValidEmployeeID(employeeId,Length) && 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,Length) && !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 symbol!");
}
else
{
printf("Error : the entered ID should contain a maximum of 20 letters");
}
}
else
{
printf("Error : the entered ID should contain a maximum of 20 letters");
printf("the Verification password and the entered password dont match");
}
}

5
src/employeesCredentialsList.txt

@ -9,8 +9,3 @@ Julius Insertcatfdai7057
Mohamed MDfdai6618
Shivam Schivam007fdlt3781
Loading…
Cancel
Save