Fonction de connection totalement valide (en attente d'une fonction de chargement valide)

master
DahmaneYanis 2 years ago
parent 798edb2945
commit b184477f43

@ -1,5 +1,5 @@
yadahmaneb Code1 yadahmaneb Code1 admin
loobry Code2 loobry Code2 admin
gurey Code3 gurey Code3 admin
andeamorin Code4 andeamorin Code4 admin
jemarcillac Code5 jemarcillac Code5 admin

@ -58,6 +58,7 @@ typedef struct log
{ {
char utilisateur[30]; char utilisateur[30];
char mdp[30]; char mdp[30];
char status[15];
}Log; }Log;
typedef struct maillonDept typedef struct maillonDept
@ -90,17 +91,19 @@ typedef struct
// sae.c // sae.c
void testJean(void); void testJean(void);
void Globale(void); void Globale(void);
Log * chargementLog(char * nomFichier, int * nbLog); Log * chargementLog(char * nomFichier, int * nbLog);
int existeUtilisateur(char * utilisateur, int * indice, Log * tLog, int nbLog); int existeUtilisateur(char * utilisateur, int * indice, Log * tLog, int nbLog);
int mdpValide(char * mdp, int indice, Log * tLog); int mdpValide(char * mdp, int indice, Log * tLog);
//void menuVisiteur(VilleIut *villeIut, int nbVilles); //void menuVisiteur(VilleIut *villeIut, int nbVilles);
void menuVisiteur(Log * tLog); void menuVisiteur(Log * tLog, int nbLog, VilleIut *tIut[], int nbVilles);
int afficherMenuVisiteur(void); int afficherMenuVisiteur(void);
int choixMenuVisiteur(void); int choixMenuVisiteur(void);
void banniereConnection(void); void banniereConnection(void);
void saisieNomUtilisateur(char * utilisateur); void saisieNomUtilisateur(char * utilisateur);
void saisieMdp(char * mdp); void saisieMdp(char * mdp);
void seConnecter(Log * tLog, int nbLog);
void seConnecterTest(void); void seConnecterTest(void);
int modifiePlacesDept(VilleIut *villeIut, int nbVilles, char *ville, char *nomDept, int nbP); int modifiePlacesDept(VilleIut *villeIut, int nbVilles, char *ville, char *nomDept, int nbP);

@ -15,13 +15,17 @@
void Globale(void) void Globale(void)
{ {
Log * tLog; Log * tLog;
VilleIut *tIut[50] ;
int nbVilles;
int nbLog; int nbLog;
//Chargement des fichiers //Chargement des fichiers
tLog = chargementLog("../donnees/log.don", &nbLog); tLog = chargementLog("../donnees/log.don", &nbLog);
nbVilles = chargIutDon(tIut, 50, "../donnees/iut.don");
//Appel du menu visiteur //Appel du menu visiteur
menuVisiteur(tLog); menuVisiteur(tLog, nbLog, tIut, nbVilles);
//Sauvegarde dans les fichiers //Sauvegarde dans les fichiers
} }
@ -71,7 +75,8 @@ Log * chargementLog(char * nomFichier, int * nbLog)
nbLogMax+= 5; nbLogMax+= 5;
} }
fscanf(fichier, "%s %s", tLog[i].utilisateur, tLog[i].mdp); fscanf(fichier, "%s %s %s", tLog[i].utilisateur, tLog[i].mdp, tLog[i].status);
printf("%s\n", tLog[i].status);
i++; i++;
} }
@ -79,13 +84,21 @@ Log * chargementLog(char * nomFichier, int * nbLog)
return tLog; return tLog;
} }
/*void test(VilleIut * tIut[], int nbVilles)
{
for (int i = 0 ; i <nbVilles ; i++)
{
printf("%s\n", tIut[i]->nom);
}
}*/
/** /**
* @brief Cette fonction affiche le menu des options disponibles pour un visiteur * @brief Cette fonction affiche le menu des options disponibles pour un visiteur
* et demande à l'utilisateur de faire son choix en appelant la fonction * et demande à l'utilisateur de faire son choix en appelant la fonction
* choixMenuVisiteur. Selon le choix de l'utilisateur, la fonction appelle la fonction correspondante * choixMenuVisiteur. Selon le choix de l'utilisateur, la fonction appelle la fonction correspondante
* ou met fin à l'exécution de la fonction. * ou met fin à l'exécution de la fonction.
*/ */
void menuVisiteur(Log * tLog) void menuVisiteur(Log * tLog, int nbLog, VilleIut *tIut[], int nbVilles)
//void menuVisiteur(VilleIut *villeIut, int nbVilles) //void menuVisiteur(VilleIut *villeIut, int nbVilles)
{ {
int choix; int choix;
@ -100,8 +113,9 @@ void menuVisiteur(Log * tLog)
switch(choix) switch(choix)
{ {
case 1: case 1:
//afficheVillesIUT(villeIut, 0); //test(tIut, nbVilles);
printf("Affiche les villes qui ont des IUT. (En attente de la fonction de chargement)\n"); //afficheVillesIUT(tIut, nbVilles);
printf("Affiche les Villes contenant des IUT (En attente d'une fonction de chargement fonctionnelle)\n");
break; break;
case 2: case 2:
printf("Affiche le nombre de place dans un departement (En attente de Guillaume)\n"); printf("Affiche le nombre de place dans un departement (En attente de Guillaume)\n");
@ -113,7 +127,7 @@ void menuVisiteur(Log * tLog)
printf("Affiche les IUT possedant un departement donne (En attente de Jean)\n"); printf("Affiche les IUT possedant un departement donne (En attente de Jean)\n");
break; break;
case 5 : case 5 :
seConnecterTest(); seConnecter(tLog, nbLog);
clean clean
break; break;
case 0 : case 0 :
@ -205,12 +219,46 @@ void seConnecterTest(void)
saisieNomUtilisateur(utilisateur); // Récupération du nom d'utilisateur saisieNomUtilisateur(utilisateur); // Récupération du nom d'utilisateur
existe = existeUtilisateur(utilisateur, &indice, tLog, nbLog); existe = existeUtilisateur(utilisateur, &indice, tLog, nbLog);
saisieMdp(mdp); // Récupération du mot de passe saisieMdp(mdp); // Récupération du mot de passe
valide = mdpValide(mdp, indice, tLog); valide = mdpValide(mdp, indice, tLog);
} }
void seConnecter(Log * tLog, int nbLog)
{
char mdp[30], utilisateur[30];
int existe, indice, valide;
banniereConnection(); // Affichage
saisieNomUtilisateur(utilisateur); // Récupération du nom d'utilisateur
existe = existeUtilisateur(utilisateur, &indice, tLog, nbLog);
if(!existe)
{
printf("Utilisateur inexistant !\nAppuyez sur [entrée] pour continuer...");
scanf("%*c");
return;
}
saisieMdp(mdp);
valide = mdpValide(mdp, indice, tLog);
if(valide)
{
printf("Connection valide en tant que %s\n", tLog[indice].status);
printf("En attente de la fonction chargement\n");
scanf("%*c");
}
else
{
printf("Mot de passe invalide\nAppuyez sur [entrée] pour continuer...");
scanf("%*c");
}
}
/** /**
* @brief Vérifie si un utilisateur existe dans le tableau de structures de log. * @brief Vérifie si un utilisateur existe dans le tableau de structures de log.
* *
@ -399,7 +447,7 @@ void menuAdmin(VilleIut *villeIut, int nbVilles)
printf("\nVotre choix: "); printf("\nVotre choix: ");
// Saisie du choix de l'utilisateur // Saisie du choix de l'utilisateur
scanf("%d", &choix); scanf("%d%*c", &choix);
// Traitement du choix de l'utilisateur // Traitement du choix de l'utilisateur
switch (choix) switch (choix)

Loading…
Cancel
Save