From 1565ff6d0efbd46ea8087f2847836f5e75b81e96 Mon Sep 17 00:00:00 2001 From: Vincent ASTOLFI Date: Wed, 14 Dec 2022 13:23:57 +0100 Subject: [PATCH] =?UTF-8?q?modif=20stub.=20Ajout=20de=20la=20possibilit?= =?UTF-8?q?=C3=A9=20de=20cr=C3=A9er=20des=20comptes=20et=20de=20changer=20?= =?UTF-8?q?le=20mot=20de=20passe=20depuis=20le=20stub?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/Data/Stub.cs | 64 +++++++++++++++++++---- Sources/IHM/Mobile/ForgetPassword.xaml.cs | 4 ++ Sources/Modele/Manager.cs | 3 -- 3 files changed, 59 insertions(+), 12 deletions(-) diff --git a/Sources/Data/Stub.cs b/Sources/Data/Stub.cs index dcf99c2..b4973f6 100644 --- a/Sources/Data/Stub.cs +++ b/Sources/Data/Stub.cs @@ -4,9 +4,28 @@ namespace Data { public class Stub : IPersistanceManager { + private List lesInscrits = new List(); + + public Stub() + { + lesInscrits.Add(new Inscrit( + "1", + "LIVET", + "livet.hugo2003@gmail.com", + "Hugo", + "Bonjour63." + )); + } public string GetId(string mail) { - return "1"; + foreach(Inscrit i in lesInscrits) + { + if(i.Mail == mail) + { + return i.Id; + } + } + return null; } public void SupprimerInscritBdd(Inscrit inscrit) { @@ -20,22 +39,45 @@ namespace Data { throw new NotImplementedException(); } - public void CreateInscrit(Inscrit inscrit){} + public void CreateInscrit(Inscrit inscrit){ + lesInscrits.Add(inscrit); + } public string LastInscrit() { return "1"; } public bool ExistEmail(string mail) { - return true; + foreach(Inscrit i in lesInscrits) + { + if(i.Mail == mail) + { + return true; + } + } + return false; } public void ChangePasswordBdd(string mail, string newMdp) { - throw new NotImplementedException(); + foreach(Inscrit i in lesInscrits) + { + if(i.Mail == mail) + { + i.Mdp = newMdp; + } + } } public string RecupMdpBdd(string mail) { - return "61202106183104184172149183829180134166241997147151111351903525172892257223616564213999421532841808077145252175106506275806214514321147161111472321892055913517616241"; + Hash hash = new Hash(); + foreach(Inscrit i in lesInscrits) + { + if(i.Mail == mail) + { + return hash.CreateHashCode(i.Mdp); + } + } + return "inexistant"; } public int CalculTotalSoldeComtpe(Inscrit user) { @@ -65,10 +107,14 @@ namespace Data public Inscrit GetInscrit(string mail) { - string mdp = "Azerty12345678!"; - Inscrit i = new Inscrit("1", "LIVET", "livet.hugo2003@gmail.com", "Hugo", mdp); - - return i; + foreach(Inscrit i in lesInscrits) + { + if(i.Mail == mail) + { + return i; + } + } + return null; } public IList GetCompteFromOFX(string ofx) diff --git a/Sources/IHM/Mobile/ForgetPassword.xaml.cs b/Sources/IHM/Mobile/ForgetPassword.xaml.cs index 44361aa..4384043 100644 --- a/Sources/IHM/Mobile/ForgetPassword.xaml.cs +++ b/Sources/IHM/Mobile/ForgetPassword.xaml.cs @@ -28,6 +28,10 @@ public partial class ForgetPassword : ContentPage ConnexionButton.IsEnabled = false; UpdateArc(); } + else + { + AffichError("Mail inexistant", "Aucun compte possédant cette adresse email trouvé", "OK"); + } } private async void AffichError(string s, string s1, string s2) { diff --git a/Sources/Modele/Manager.cs b/Sources/Modele/Manager.cs index 012177c..0ca01b4 100644 --- a/Sources/Modele/Manager.cs +++ b/Sources/Modele/Manager.cs @@ -28,10 +28,7 @@ namespace Model private int solde; - - private Inscrit user; - public Inscrit User { get