private void Connexion(object obj) { try { pwBox = obj as PasswordBox; TherapeuteDB therapeute = AdminData.Connexion(NomUtilisateur, pwBox.Password); if (therapeute != null) { Singleton.identificationAdmin(); Singleton singletonAdmin = Singleton.getInstance(); singletonAdmin.Admin = (new Admin(therapeute.Nom, therapeute.Prenom, therapeute.Login, therapeute.MotDePasse)); NomUtilisateur = null; SimpleIoc.Default.GetInstance <INavigation>().NavigateTo <HomeViewModel>(true); //log le thérapeut connecté logger.Info("Connexion de " + therapeute.Prenom + " " + therapeute.Nom + " Login : " + therapeute.Login); } else { MessageBox.Show(AxLanguage.Languages.REAplan_Connexion_Erreur2, AxLanguage.Languages.REAplan_Inscription_Erreur, MessageBoxButton.OK, MessageBoxImage.Error); } } catch (Exception ex) { GestionErreur.GerrerErreur(ex); } }
private void MoveToInscription(object obj) { try { pwBox = obj as PasswordBox; TherapeuteDB therapeute = AdminData.Connexion(NomUtilisateur, pwBox.Password); if (therapeute != null) { if (AdminData.IsAdministrateur(NomUtilisateur, pwBox.Password)) { NomUtilisateur = null; //Nom = null; //Prenom = null; FirstTime = true; InternView = PagesInternes[1]; } else { MessageBox.Show(AxLanguage.Languages.REAplan_Impossible_Enregistrer_Utilisateur, AxLanguage.Languages.REAplan_Inscription_Erreur, MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show(AxLanguage.Languages.REAplan_Connexion_Erreur, AxLanguage.Languages.REAplan_Inscription_Erreur, MessageBoxButton.OK, MessageBoxImage.Error); } } catch (Exception ex) { GestionErreur.GerrerErreur(ex); } }
//Permet de savoir si un admin est présent dans la bd public static bool AdminInBd() { //permet au TU de donner la fausse BD if (conn == null) { bdd = new ReaPlanDBEntities(); } else { bdd = new ReaPlanDBEntities(conn); } using (bdd) { var requete = from c in bdd.TherapeuteDBs where c.Administrateur == true select c; TherapeuteDB admin = requete.FirstOrDefault(); if (admin == null) { return(false); } else { return(true); } } }
public static void InscriptionTherapeute(string nom, string prenom, string login, string pass, bool isAdmin) { //permet au TU de donner la fausse BD if (conn == null) { bdd = new ReaPlanDBEntities(); } else { bdd = new ReaPlanDBEntities(conn); } nom = nom.ToUpper(); using (bdd) { //Cryptage du mot de passe if (pass != null) { string passwordTmp = login.ToLower() + pass; UTF8Encoding textConverter = new UTF8Encoding(); byte[] passBytes = textConverter.GetBytes(passwordTmp); pass = Convert.ToBase64String(new SHA384Managed().ComputeHash(passBytes)); } TherapeuteDB thera = TherapeuteDB.CreateTherapeuteDB(nom, prenom, login, pass); if (isAdmin == true) { thera.Administrateur = true; } bdd.AddToTherapeuteDBs(thera); bdd.SaveChanges(); } }
public static TherapeuteDB Connexion(string login, string pass) { //permet au TU de donner la fausse BD if (conn == null) { bdd = new ReaPlanDBEntities(); UiServices.SetBusyState(); } else { bdd = new ReaPlanDBEntities(conn); } //Cryptage du mot de passe entré pour le comparer avec le mdp crypté de la bd if (pass != null && login != null) { string password = login.ToLower() + pass; UTF8Encoding textConverter = new UTF8Encoding(); byte[] passBytes = textConverter.GetBytes(password); pass = Convert.ToBase64String(new SHA384Managed().ComputeHash(passBytes)); } using (bdd) { var requete = from c in bdd.TherapeuteDBs where c.Login == login && c.MotDePasse == pass select c; TherapeuteDB therapeute = requete.FirstOrDefault(); return(therapeute); } }
public static bool IsAdministrateur(string login, string pass) { TherapeuteDB thera = Connexion(login, pass); if (thera != null) { return(thera.Administrateur); } else { return(false); } }
public void Init() { EntityConnection connection = Effort.EntityConnectionFactory.CreateTransient("name=ReaPlanDBEntities"); context = new ReaPlanDBEntities(connection); //creation d'un faux therapeute adminstrateur pass = "******";// = admin thera = TherapeuteDB.CreateTherapeuteDB("pedro", "drope", "admin", pass); thera.Administrateur = true; context.AddToTherapeuteDBs(thera); //creation d'un faux therapeute non adminstrateur pass = "******";// = 123456 thera = TherapeuteDB.CreateTherapeuteDB("jacko", "michel", "jackmich", pass); thera.Administrateur = false; context.AddToTherapeuteDBs(thera); context.SaveChanges(); AdminData.conn = connection; }