|
@ -4,19 +4,11 @@ |
|
|
bool employeesAccess(char* employeesAccessCode) |
|
|
bool employeesAccess(char* employeesAccessCode) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
if(strcmp(employeesAccessCode,employeeAccessKey) == 0) |
|
|
|
|
|
{ |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return !(strcmp(employeesAccessCode,employeeAccessKey)); |
|
|
|
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
extern int checkEmployeeCredentials(char *inputUsername, char *inputPassword) |
|
|
|
|
|
|
|
|
int checkEmployeeCredentials(char *inputUsername, char *inputPassword) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
char* listUsername = malloc(credentialLength * sizeof(char*)); |
|
|
char* listUsername = malloc(credentialLength * sizeof(char*)); |
|
@ -55,21 +47,19 @@ extern int checkEmployeeCredentials(char *inputUsername, char *inputPassword) |
|
|
free(inputPassword); |
|
|
free(inputPassword); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void inputEmployeeAccessCode() |
|
|
|
|
|
|
|
|
void getEmployeeAccessCode() |
|
|
{ |
|
|
{ |
|
|
char accessKey[10]; |
|
|
|
|
|
|
|
|
char accessCode[10]; |
|
|
|
|
|
|
|
|
int remainingAttempts = 10; |
|
|
int remainingAttempts = 10; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf("\n\nPlease enter the Access key : "); |
|
|
printf("\n\nPlease enter the Access key : "); |
|
|
// scanf("%s",accessKey); |
|
|
|
|
|
|
|
|
|
|
|
while(remainingAttempts > 0) |
|
|
while(remainingAttempts > 0) |
|
|
{ |
|
|
{ |
|
|
scanf("%s",accessKey); |
|
|
|
|
|
|
|
|
scanf("%s",accessCode); |
|
|
|
|
|
|
|
|
if(employeesAccess(accessKey)==true) |
|
|
|
|
|
|
|
|
if(employeesAccess(accessCode)) |
|
|
{ |
|
|
{ |
|
|
printf("\n\nAccess granted!\n\n"); |
|
|
printf("\n\nAccess granted!\n\n"); |
|
|
|
|
|
|
|
@ -77,22 +67,22 @@ void inputEmployeeAccessCode() |
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
--remainingAttempts; |
|
|
|
|
|
printf("\n\nAccess key didnt match! try again !\n\n"); |
|
|
printf("\n\nAccess key didnt match! try again !\n\n"); |
|
|
|
|
|
|
|
|
|
|
|
--remainingAttempts; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if(remainingAttempts == 0) |
|
|
if(remainingAttempts == 0) |
|
|
{ |
|
|
{ |
|
|
printf("you've reached the maximum number of tries!\nplease contact an employee of a high clearance(2 or higher) \n\n"); |
|
|
printf("you've reached the maximum number of tries!\nplease contact an employee of a high clearance(2 or higher) \n\n"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void employeeCredentials(char* inputUsername,char* inputPassword) |
|
|
|
|
|
|
|
|
void getEmployeeCredentials(char* inputUsername,char* inputPassword) |
|
|
{ |
|
|
{ |
|
|
printf("Enter username: "); |
|
|
printf("Enter username: "); |
|
|
scanf("%s", inputUsername); |
|
|
scanf("%s", inputUsername); |
|
@ -108,7 +98,7 @@ void loginAsEmployee() |
|
|
|
|
|
|
|
|
while(counter>0) |
|
|
while(counter>0) |
|
|
{ |
|
|
{ |
|
|
employeeCredentials(username, password); |
|
|
|
|
|
|
|
|
getEmployeeCredentials(username, password); |
|
|
|
|
|
|
|
|
int checkCredentials = checkEmployeeCredentials(username,password); |
|
|
int checkCredentials = checkEmployeeCredentials(username,password); |
|
|
|
|
|
|
|
|