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. 28
      src/createEmployeeAccount.c
  2. 5
      src/employeesCredentialsList.txt

28
src/createEmployeeAccount.c

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

5
src/employeesCredentialsList.txt

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