diff --git a/src/errorHandling.c b/src/errorHandling.c index 4841ac5..38cac7a 100644 --- a/src/errorHandling.c +++ b/src/errorHandling.c @@ -15,7 +15,7 @@ void errorHandling(int error) //? Exemple d'erreurs (à adapter) if (error < 0) { - printf("\a"); // Bip d'erreur + printf("\a \x1B[31m"); // Bip d'erreur switch (error) { case -1: @@ -49,11 +49,12 @@ void errorHandling(int error) printf("[ERREUR] - Une erreur s'est produite.\n"); break; } + printf("\x1B[0m"); } } /** - * La fonction `debugHandling` aide au debug en écrivant du texte selon l'entrée. + * @brief La fonction `debugHandling` aide au debug en écrivant du texte selon l'entrée. * * @param code Entier qui représente l'entrée. */ diff --git a/src/exe b/src/exe index 57ce5e4..278a014 100755 Binary files a/src/exe and b/src/exe differ diff --git a/src/login.c b/src/login.c index 3e53c34..bc97528 100644 --- a/src/login.c +++ b/src/login.c @@ -88,6 +88,12 @@ int signup(int clientID[], int clientPassword[], float cagnotte[], int suspended printf("Erreur, l'identifiant doit être positif, entrez votre identifiant ou 0 si vous souhaitez quitter: "); scanf("%d%*c", &id); } + if (id == 0) + { + errorHandling(-1); + return -1; + } + index = searchTab(clientID, id, *tlog, &found); while(found == 1) { @@ -95,6 +101,7 @@ int signup(int clientID[], int clientPassword[], float cagnotte[], int suspended scanf("%d%*c", &id); if (id == 0) { + errorHandling(-1); return -1; } index = searchTab(clientID, id, *tlog, &found); diff --git a/src/main.c b/src/main.c index 73224b8..b6a7408 100644 --- a/src/main.c +++ b/src/main.c @@ -17,7 +17,6 @@ int displayMenu(void) int choice; printf("\nTapez sur Entrée pour continuer..."); - //TODO Clear le buffer pour éviter les problèmes if (getchar() == '\n') // getchar() pour récupérer le caractère entré par l'utilisateur { system("clear"); // Clear le terminal @@ -75,7 +74,7 @@ void global(void) else { printf("Connexion échouée.\nRetour au menu principal...\n"); - sleep(3); + sleep(2); } break; case 2: @@ -92,8 +91,7 @@ void global(void) } break; case 3: - //TODO > Faire opposition - //opposition(); + opposition(clientID, clientPassword, suspended, tLogClient); break; case 4: sauvegardeDonnees(tLogItem, tLogClient, reference, weight, volume, unitPrice, clientID, clientPassword, cagnotte, isAdmin, suspended); diff --git a/src/main.h b/src/main.h index 3cfefa9..3e4f692 100644 --- a/src/main.h +++ b/src/main.h @@ -69,4 +69,5 @@ int decrypt(int password); //! MENUS void adminMenu(int clientID[], int clientPassword[], float cagnotte[], int suspended[], int isAdmin[], int tabReference[], float tabWeight[], float tabVolume[], float unitPrice[], int *tlogItem, int *tlogClient); -void clientMenu(float *weight, float *volume, float *price, int tabItemRef[], float unitPrice[], float *cagnotte, int basket_tab_ref[], int basket_tab_qte[], float tabWeight[], float tabVolume[], int tlogItem, int *tlogBasket); \ No newline at end of file +void clientMenu(float *weight, float *volume, float *price, int tabItemRef[], float unitPrice[], float *cagnotte, int basket_tab_ref[], int basket_tab_qte[], float tabWeight[], float tabVolume[], int tlogItem, int *tlogBasket); +void opposition(int clientID[], int clientPassword[], int suspended[], int tlogClient) \ No newline at end of file diff --git a/src/menu.c b/src/menu.c index eec8827..e19887c 100644 --- a/src/menu.c +++ b/src/menu.c @@ -69,7 +69,7 @@ void clientMenu(float *weight, float *volume, float *price, int tabItemRef[], fl } /** - * La fonction `adminMenu` permet à l'utilisateur administrateur de pouvoir utiliser des fonctions permettant + * @brief La fonction `adminMenu` permet à l'utilisateur administrateur de pouvoir utiliser des fonctions permettant * d'ajouter/supprimer/modifier des articles du panier/ des clients, et afficher les informations * du client/de l'article. * @@ -144,4 +144,37 @@ void adminMenu(int clientID[], int clientPassword[], float cagnotte[], int suspe break; } } +} + +/** + * @brief Pour faire opposition et débloquer son compte lorsqu'il est suspendu. + * @param clientID Tableau des identifiants client + * @param clientPassword Tableau des mots de passe + * @param suspended Tableau des états de compte + * @param tlogClient Taille logique du tableau des clients + * + * @return void +*/ +void opposition(int clientID[], int clientPassword[], int suspended[], int tlogClient) +{ + int id, password, index, found; + printf("Entrez votre identifiant: "); + scanf("%d%*c", &id); + index = searchTab(clientID, id, tlogClient, &found); + if (found == 0) + { + errorHandling(-7); + return; + } + printf("Entrez votre mot de passe: "); + scanf("%d%*c", &password); + if (password == clientPassword[index]) + { + suspended[index] = 0; + printf("Votre compte a été réactivé.\n"); + } + else + { + errorHandling(-9); + } } \ No newline at end of file