@ -97,18 +97,18 @@ bool createNewEmployee(char* employeeId, char* employeePassword)
void getNewEmployeeCredentials ( )
void getNewEmployeeCredentials ( )
{
{
const int employeeId Length = 21 ;
char employeeId [ employeeId Length] ;
const int Length = 21 ;
char employeeId [ Length ] ;
const int minimumPasswordLength = 5 ;
const int minimumPasswordLength = 5 ;
char employeePassword [ minimumPassword Length] ;
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 [ employeeId Length] = ' \0 ' ;
employeeId [ Length ] = ' \0 ' ;
printf ( " \n please enter your wished Password : \n " ) ;
printf ( " \n please 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 ( " \n please 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! " ) ;
}
}
@ -131,5 +140,10 @@ void getNewEmployeeCredentials()
printf ( " Error : the entered ID should contain a maximum of 20 letters " ) ;
printf ( " Error : the entered ID should contain a maximum of 20 letters " ) ;
}
}
}
else
{
printf ( " the Verification password and the entered password dont match " ) ;
}
}
}