refactoring du manager pour la page MainWindow
continuous-integration/drone/push Build is failing Details

ManagerRefactoring
Vincent ASTOLFI 2 years ago
parent 782d82eb74
commit c7bee1a4d6

@ -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();

@ -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";

@ -11,7 +11,7 @@ public partial class AjoutBanques : ContentPage
{
InitializeComponent();
BindingContext = Mgr;
Mgr.importBanques();
//Mgr.importBanques();
if (OperatingSystem.IsIOS())
{
boutonRetour.IsVisible = true;

@ -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();
}

@ -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();
}
}
}

@ -12,8 +12,6 @@ namespace Model
{
public class Inscrit:INotifyPropertyChanged
{
public Hash hash = new Hash();
public event PropertyChangedEventHandler PropertyChanged;
public int Id { get; set; }

@ -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);
}
}
}

Loading…
Cancel
Save