diff --git a/VeraxShield/VeraxShield/Properties/launchSettings.json b/VeraxShield/VeraxShield/Properties/launchSettings.json index f8d53ec..1b433a7 100644 --- a/VeraxShield/VeraxShield/Properties/launchSettings.json +++ b/VeraxShield/VeraxShield/Properties/launchSettings.json @@ -1,28 +1,22 @@ { - "iisSettings": { - "iisExpress": { - "applicationUrl": "http://localhost:38362", - "sslPort": 44368 - } - }, "profiles": { "http": { "commandName": "Project", - "dotnetRunMessages": true, "launchBrowser": true, - "applicationUrl": "http://localhost:5272", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" - } + }, + "dotnetRunMessages": true, + "applicationUrl": "http://localhost:5272" }, "https": { "commandName": "Project", - "dotnetRunMessages": true, "launchBrowser": true, - "applicationUrl": "https://localhost:7112;http://localhost:5272", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" - } + }, + "dotnetRunMessages": true, + "applicationUrl": "https://localhost:7112;http://localhost:5272" }, "IIS Express": { "commandName": "IISExpress", @@ -30,6 +24,24 @@ "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } + }, + "WSL": { + "commandName": "WSL2", + "launchBrowser": true, + "launchUrl": "https://localhost:7112", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development", + "ASPNETCORE_URLS": "https://localhost:7112;http://localhost:5272" + }, + "distributionName": "" + } + }, + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:38362", + "sslPort": 44368 } } -} +} \ No newline at end of file diff --git a/VeraxShield/VeraxShield/services/UtilisateursDataService/UtilisateursDataServiceFactice.cs b/VeraxShield/VeraxShield/services/UtilisateursDataService/UtilisateursDataServiceFactice.cs index 1c17e52..d6ce64a 100644 --- a/VeraxShield/VeraxShield/services/UtilisateursDataService/UtilisateursDataServiceFactice.cs +++ b/VeraxShield/VeraxShield/services/UtilisateursDataService/UtilisateursDataServiceFactice.cs @@ -38,80 +38,93 @@ namespace VeraxShield.services.UtilisateursDataService if (lUtilisateurs.Count == 0) { lUtilisateurs = await this.getUtilisateursFromJson(this.EmplacementJson); - - await this.saveUtilisateursLocalStorage(lUtilisateurs); - - Console.WriteLine("--> Le contenu du local storage a été écrasé !"); - } - - return lUtilisateurs; - } - - public async Task resetDataUtilisateurs() - { - List lUtilisateurs = new List(); - lUtilisateurs = await this.getUtilisateursFromJson(this.EmplacementJson); - await this.saveUtilisateursLocalStorage(lUtilisateurs); - - Console.WriteLine("Local storage reset !"); - } - - public async Task SaveAllUtilisateurs(List list) - { - await this.saveUtilisateursLocalStorage(list); - } - - public async Task AjouterUtilisateur(Utilisateur u) - { - List data = await this.getAllUtilisateurs(); - data.Add(u); - await this.SaveAllUtilisateurs(data); - } - - public async Task SupprimerUtilisateur(Utilisateur u) - { - List data = await this.getAllUtilisateurs(); - - foreach (Utilisateur temp in data) - { - Console.WriteLine(" - d : " + temp.Pseudo); - } - - int index = -1; - - foreach(Utilisateur temp in data) - { - if (temp.Pseudo == u.Pseudo) - { - index = data.IndexOf(temp); - } - } - - Console.WriteLine("Index : " + index); - - if (index != -1) - { - data.RemoveAt(index); - } - - await this.SaveAllUtilisateurs(data); - - Console.WriteLine("L'utilisateur " + u.Pseudo + "supprimé !"); - - data = await this.getAllUtilisateurs(); - - foreach (Utilisateur temp in data) - { - Console.WriteLine(temp.Pseudo); + // Cette boucle permet de hach les mdp des user du json + foreach (var user in lUtilisateurs) + { + var motDePasseClair = user.Mdp; + // Hach du mot de passe + user.Mdp = BCrypt.Net.BCrypt.HashPassword(motDePasseClair); + System.Console.WriteLine(user); + + + } + + System.Console.WriteLine(lUtilisateurs); + + await this.saveUtilisateursLocalStorage(lUtilisateurs); + + Console.WriteLine("--> Le contenu du local storage a été écrasé !"); } - } - public async Task MettreAJourUtilisateur(Utilisateur u) - { - await this.SupprimerUtilisateur(u); - await this.AjouterUtilisateur(u); - } + return lUtilisateurs; + } + + public async Task resetDataUtilisateurs() + { + List lUtilisateurs = new List(); + lUtilisateurs = await this.getUtilisateursFromJson(this.EmplacementJson); + await this.saveUtilisateursLocalStorage(lUtilisateurs); + + Console.WriteLine("Local storage reset !"); + } + + public async Task SaveAllUtilisateurs(List list) + { + await this.saveUtilisateursLocalStorage(list); + } + + public async Task AjouterUtilisateur(Utilisateur u) + { + List data = await this.getAllUtilisateurs(); + data.Add(u); + await this.SaveAllUtilisateurs(data); + } + + public async Task SupprimerUtilisateur(Utilisateur u) + { + List data = await this.getAllUtilisateurs(); + + foreach (Utilisateur temp in data) + { + Console.WriteLine(" - d : " + temp.Pseudo); + } + + int index = -1; + + foreach(Utilisateur temp in data) + { + if (temp.Pseudo == u.Pseudo) + { + index = data.IndexOf(temp); + } + } + + Console.WriteLine("Index : " + index); + + if (index != -1) + { + data.RemoveAt(index); + } + + await this.SaveAllUtilisateurs(data); + + Console.WriteLine("L'utilisateur " + u.Pseudo + "supprimé !"); + + data = await this.getAllUtilisateurs(); + + foreach (Utilisateur temp in data) + { + Console.WriteLine(temp.Pseudo); + } + } + + public async Task MettreAJourUtilisateur(Utilisateur u) + { + await this.SupprimerUtilisateur(u); + await this.AjouterUtilisateur(u); + } + public async Task MettreAJourUtilisateur(Utilisateur ancienneVersion, Utilisateur nouvelleVersion) { await this.SupprimerUtilisateur(ancienneVersion);