From 0d9a5188f5973663d01067062014f943abbd06c1 Mon Sep 17 00:00:00 2001 From: hulivet1 Date: Fri, 6 Jan 2023 13:38:39 +0100 Subject: [PATCH] Modif vues --- Sources/Data/PersAPI.cs | 11 ++++++----- Sources/Data/PersStub.cs | 2 +- Sources/IHM/Mobile/MainPage.xaml.cs | 2 +- Sources/Modele/IPersistanceManager.cs | 2 +- Sources/Modele/Inscrit.cs | 4 ++-- Sources/Modele/Manager.cs | 8 ++++---- 6 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Sources/Data/PersAPI.cs b/Sources/Data/PersAPI.cs index 9632e64..93e1bda 100644 --- a/Sources/Data/PersAPI.cs +++ b/Sources/Data/PersAPI.cs @@ -26,14 +26,15 @@ namespace Data { return ClientAPI.PutPasswordInscritAsync(mail,nouveauMdp).GetAwaiter().GetResult(); } - public Inscrit RecupererInscrit(string mail) + public async Task RecupererInscrit(string mail) { - List inscrits = ClientAPI.GetInscritAsync(mail).GetAwaiter().GetResult(); - if(inscrits.Count >= 1) + List inscrits = await ClientAPI.GetInscritAsync(mail); + if(inscrits.Count == 1) { - throw new ArgumentException("Cet email contient plusieurs utilisateurs pour la même adresse"); + return inscrits.First(); } - return inscrits.FirstOrDefault(); + throw new ArgumentException("Cet email a un problème"); + } public async Task EmailDisponible(string mail) { diff --git a/Sources/Data/PersStub.cs b/Sources/Data/PersStub.cs index c91bb20..a6cd4f6 100644 --- a/Sources/Data/PersStub.cs +++ b/Sources/Data/PersStub.cs @@ -221,7 +221,7 @@ namespace Data throw new NotImplementedException(); } - public Inscrit RecupererInscrit(string mail) + public Task RecupererInscrit(string mail) { throw new NotImplementedException(); } diff --git a/Sources/IHM/Mobile/MainPage.xaml.cs b/Sources/IHM/Mobile/MainPage.xaml.cs index b9d650c..ce6e963 100644 --- a/Sources/IHM/Mobile/MainPage.xaml.cs +++ b/Sources/IHM/Mobile/MainPage.xaml.cs @@ -23,7 +23,7 @@ namespace IHM.Mobile else { if (await Mgr.Pers.EmailDisponible(EntryMail.Text)) { - if (Mgr.CompareHash(Mgr.getPassword(EntryMail.Text), EntryPassworld.Text)) + if (Mgr.CompareHash(await Mgr.getPassword(EntryMail.Text), EntryPassworld.Text)) { Mgr.createUser(EntryMail.Text); ConnexionValide(); diff --git a/Sources/Modele/IPersistanceManager.cs b/Sources/Modele/IPersistanceManager.cs index 6b29a30..40dbe52 100644 --- a/Sources/Modele/IPersistanceManager.cs +++ b/Sources/Modele/IPersistanceManager.cs @@ -15,7 +15,7 @@ namespace Model Task AjouterInscrit(Inscrit inscrit); bool SupprimerInscrit(Inscrit inscrit); bool ModifierMdpInscrit(string mail, string nouveauMdp); - Inscrit RecupererInscrit(string mail); + Task RecupererInscrit(string mail); Task EmailDisponible(string mail); diff --git a/Sources/Modele/Inscrit.cs b/Sources/Modele/Inscrit.cs index 6f5ccb5..69ff5fd 100644 --- a/Sources/Modele/Inscrit.cs +++ b/Sources/Modele/Inscrit.cs @@ -43,7 +43,7 @@ namespace Model get => mdp; set { - if (value.Length <= 8) + /*if (value.Length <= 8) { throw new InvalidPasswordException(value, "La longeur d'un mot de passe doit être obligatoirement superieure a 8"); } @@ -54,7 +54,7 @@ namespace Model if (!Regex.IsMatch(value, "[0-9]+")) { throw new InvalidPasswordException(value, "Le mot de passe doit contenir au moins un chiffre"); - } + }*/ mdp = value; } } diff --git a/Sources/Modele/Manager.cs b/Sources/Modele/Manager.cs index 8a0e98e..597c7ca 100644 --- a/Sources/Modele/Manager.cs +++ b/Sources/Modele/Manager.cs @@ -78,15 +78,15 @@ namespace Model BanquesDisponibleInApp = Pers.RecupererBanquesDisponible(); } - public string getPassword(string email) + public async Task getPassword(string email) { - Inscrit inscrit = Pers.RecupererInscrit(email); + Inscrit inscrit = await Pers.RecupererInscrit(email); return inscrit.Mdp; } - public void createUser(string mail) + public async void createUser(string mail) { - User = Pers.RecupererInscrit(mail); + User = await Pers.RecupererInscrit(mail); } } }