Browse Source

refactoring: changed some variables names and added some comments for documentation and enhanced the getnewEmployeeCredentials function.

remotes/origin/feature/employees-infos-access
fdai7207 2 years ago
parent
commit
e570fb9f66
  1. 23
      src/createEmployeeAccount.c

23
src/createEmployeeAccount.c

@ -20,18 +20,19 @@ bool isValidEmployeeID(char* employeeId)
bool createNewEmployee(char* employeeId, char* employeePassword) bool createNewEmployee(char* employeeId, char* employeePassword)
{ {
FILE* employeesList;
employeesList = fopen("src/employeeList.txt","a");
FILE* employeesFile;
employeesFile = fopen("src/employeeList.txt","a");
if(employeesList == NULL)
if(employeesFile == NULL)
{ {
printf("Error: could not open the list of Employees");
printf("Error: could not find the list of Employees");
return false; return false;
} }
fprintf(employeesList,"\n%s %s\n",employeeId,employeePassword);
fclose(employeesList);
fprintf(employeesFile,"\n%s %s\n",employeeId,employeePassword);
fclose(employeesFile);
/*used the checkEmployeeCredentials to check if the new id and password are created successfully*/
return checkEmployeeCredentials(employeeId, employeePassword); return checkEmployeeCredentials(employeeId, employeePassword);
} }
@ -46,12 +47,6 @@ void getNewEmployeeCredentials()
printf("please enter your wished Password :"); printf("please enter your wished Password :");
scanf("%s",newEmployeePassword); scanf("%s",newEmployeePassword);
if(createNewEmployee(newEmployeeId,newEmployeePassword))
{
printf("\n\n Account created successfully !\n\n");
}
else
{
printf("\n\n Could not create the Account please contact an employee of clearance 1 !\n\n");
}
createNewEmployee(newEmployeeId,newEmployeePassword) ? 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");
} }
Loading…
Cancel
Save