Browse Source

implement the function inputEmployeeAccessCode() so that only employees can access the loginAsEmployee() function.

remotes/origin/feature/the-main-menu
fdai7207 2 years ago
parent
commit
557709bdd6
  1. 1
      build-project.sh
  2. 39
      src/employeeLogin.c
  3. 2
      src/employeeLogin.h
  4. 2
      src/mainMenu.c

1
build-project.sh

@ -1,3 +1,4 @@
trap 'echo "Interrupted"; rm main; cp employeeLogin.c.bak employeeLogin.c; rm employeeLogin.c.bak; cd ..; rm -r build/; exit' SIGINT
clear
ceedling test:all
cd src/

39
src/employeeLogin.c

@ -4,7 +4,7 @@
bool employeesAccess(char* employeesAccessCode)
{
if(strcmp(employeesAccessCode,accessKey) == 0)
if(strcmp(employeesAccessCode,employeeAccessKey) == 0)
{
return true;
}
@ -55,6 +55,43 @@ extern int checkEmployeeCredentials(char *inputUsername, char *inputPassword)
free(inputPassword);
}
void inputEmployeeAccessCode()
{
char accessKey[10];
int remainingAttempts = 10;
printf("\n\nPlease enter the Access key : ");
// scanf("%s",accessKey);
while(remainingAttempts>0)
{
scanf("%s",accessKey);
if(employeesAccess(accessKey)==true)
{
printf("\n\nAccess granted!\n\n");
loginAsEmployee();
break;
}
else
{
--remainingAttempts;
printf("\n\nAccess key didnt match! try again !\n\n");
}
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");
}
}
}
void employeeCredentials(char* inputUsername,char* inputPassword)
{
printf("Enter username: ");

2
src/employeeLogin.h

@ -1,7 +1,7 @@
#ifndef LOGINEMPLOYEE_H_
#define LOGINEMPLOYEE_H_
#define accessKey "DF9E9A8B5E"
#define employeeAccessKey "DF9E9A8B5E"
#define credentialLength 20
#include<stdbool.h>

2
src/mainMenu.c

@ -107,7 +107,7 @@ void menuInput()
case 2 : printf("\ncreateCostumerAccount() function will be implemented here soon\n\n");
break;
case 3 : loginAsEmployee();
case 3 : inputEmployeeAccessCode();
break;
case 4 : printf("\e[1;1H\e[2J");

Loading…
Cancel
Save