diff --git a/Sources/Data/PersLinqToPgSQL.cs b/Sources/Data/PersLinqToPgSQL.cs index 52a82a9..3790c61 100644 --- a/Sources/Data/PersLinqToPgSQL.cs +++ b/Sources/Data/PersLinqToPgSQL.cs @@ -19,7 +19,6 @@ namespace LinqToPgSQL { public class PersLinqToPgSQL /*: IPersistanceManager*/ { - private Hash hash = new Hash(); private static string connexionBDD = String.Format("Server=2.3.8.130; Username=postgres; Database=conseco; Port=5432; Password=lulu; SSLMode=Prefer"); private static NpgsqlConnection dbAccess = new NpgsqlConnection(connexionBDD); @@ -100,8 +99,7 @@ namespace LinqToPgSQL public async void ChangePasswordBdd(string mail, string newMdp) { - Hash hash = new Hash(); - string hashedMdp = hash.CreateHashCode(newMdp); + string hashedMdp = Hash.CreateHashCode(newMdp); var conn = new NpgsqlConnection(connexionBDD); Console.Out.WriteLine("Ouverture de la connection"); try @@ -151,7 +149,7 @@ namespace LinqToPgSQL public async void CreateInscrit(Inscrit inscrit) { - string mdpHash = hash.CreateHashCode(inscrit.Mdp); + string mdpHash = Hash.CreateHashCode(inscrit.Mdp); Console.WriteLine("AAAAAA"+mdpHash.Length); var conn = new NpgsqlConnection(connexionBDD); conn.Open(); diff --git a/Sources/Data/PersStub.cs b/Sources/Data/PersStub.cs index 57a6162..e990814 100644 --- a/Sources/Data/PersStub.cs +++ b/Sources/Data/PersStub.cs @@ -90,12 +90,11 @@ namespace Data } public string RecupMdpBdd(string mail) { - Hash hash = new Hash(); foreach(Inscrit i in lesInscrits) { if(i.Mail == mail) { - return hash.CreateHashCode(i.Mdp); + return Hash.CreateHashCode(i.Mdp); } } return "inexistant"; diff --git a/Sources/IHM/Mobile/AjoutBanques.xaml.cs b/Sources/IHM/Mobile/AjoutBanques.xaml.cs index 6d7e9c1..fd4e7d6 100644 --- a/Sources/IHM/Mobile/AjoutBanques.xaml.cs +++ b/Sources/IHM/Mobile/AjoutBanques.xaml.cs @@ -11,7 +11,7 @@ public partial class AjoutBanques : ContentPage { InitializeComponent(); BindingContext = Mgr; - Mgr.importBanques(); + //Mgr.importBanques(); if (OperatingSystem.IsIOS()) { boutonRetour.IsVisible = true; diff --git a/Sources/IHM/Mobile/MainPage.xaml.cs b/Sources/IHM/Mobile/MainPage.xaml.cs index 8d020b6..a92fc19 100644 --- a/Sources/IHM/Mobile/MainPage.xaml.cs +++ b/Sources/IHM/Mobile/MainPage.xaml.cs @@ -21,9 +21,9 @@ namespace IHM.Mobile AffichError("Champ invalide", "Veuillez compléter tout les champs", "OK"); } else { - /* if (Mgr.existEmail(EntryMail.Text)) + if (Mgr.Pers.EmailDisponible(EntryMail.Text)) { - if (Mgr.isEqualHash(Mgr.recupMdpBdd(EntryMail.Text), EntryPassworld.Text)) + if (Mgr.CompareHash(Mgr.getPassword(EntryMail.Text), EntryPassworld.Text)) { Mgr.createUser(EntryMail.Text); ConnexionValide(); @@ -36,13 +36,13 @@ namespace IHM.Mobile else { AffichError("Compte inexistant", "Email ou mot de passe invalide", "OK"); - }*/ + } } } private async void ConnexionValide() { - //Mgr.LoadBanques(); + Mgr.LoadBanques(); await Navigation.PopModalAsync(); } diff --git a/Sources/Modele/Hash.cs b/Sources/Modele/Hash.cs index 2488f66..1ec1c95 100644 --- a/Sources/Modele/Hash.cs +++ b/Sources/Modele/Hash.cs @@ -7,9 +7,9 @@ using System.Text; namespace Model { - public class Hash + public static class Hash { - public string CreateHashCode(string mdp) + public static string CreateHashCode(string mdp) { string hashString = ""; @@ -25,21 +25,10 @@ namespace Model return hashString; } - public bool IsEqualHash(string mdpBdd, string mdpSent) + public static bool IsEqualHash(string mdpBdd, string mdpSent) { - string hashedMdpSent = CreateHashCode(mdpSent); + string hashedMdpSent = Hash.CreateHashCode(mdpSent); return hashedMdpSent.Equals(mdpBdd); } - - private string ByteArrayToString(byte[] arrInput) - { - int i; - StringBuilder sOutput = new StringBuilder(arrInput.Length); - for (i = 0; i < arrInput.Length; i++) - { - sOutput.Append(arrInput[i].ToString("X2")); - } - return sOutput.ToString(); - } } } diff --git a/Sources/Modele/Inscrit.cs b/Sources/Modele/Inscrit.cs index 00c7d0e..6f5ccb5 100644 --- a/Sources/Modele/Inscrit.cs +++ b/Sources/Modele/Inscrit.cs @@ -12,8 +12,6 @@ namespace Model { public class Inscrit:INotifyPropertyChanged { - public Hash hash = new Hash(); - public event PropertyChangedEventHandler PropertyChanged; public int Id { get; set; } diff --git a/Sources/Modele/Manager.cs b/Sources/Modele/Manager.cs index 1f374f4..8a0e98e 100644 --- a/Sources/Modele/Manager.cs +++ b/Sources/Modele/Manager.cs @@ -11,8 +11,6 @@ namespace Model public int SelectedInscrit { get; set; } - public Hash hash = new Hash(); - private Inscrit user; public Inscrit User { @@ -67,7 +65,7 @@ namespace Model public bool CompareHash(string mdpBdd, string mdpSent) { - return hash.IsEqualHash(mdpBdd, mdpSent); + return Hash.IsEqualHash(mdpBdd, mdpSent); } public void deconnexion() @@ -80,6 +78,16 @@ namespace Model BanquesDisponibleInApp = Pers.RecupererBanquesDisponible(); } + public string getPassword(string email) + { + Inscrit inscrit = Pers.RecupererInscrit(email); + return inscrit.Mdp; + } + + public void createUser(string mail) + { + User = Pers.RecupererInscrit(mail); + } } }