Ajout Hash user localStorage

serviceApiJean
Tony Fages 1 year ago
parent 025a8e1b0c
commit 7948d0eecd

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

@ -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<Utilisateur> lUtilisateurs = new List<Utilisateur>();
lUtilisateurs = await this.getUtilisateursFromJson(this.EmplacementJson);
await this.saveUtilisateursLocalStorage(lUtilisateurs);
Console.WriteLine("Local storage reset !");
}
public async Task SaveAllUtilisateurs(List<Utilisateur> list)
{
await this.saveUtilisateursLocalStorage(list);
}
public async Task AjouterUtilisateur(Utilisateur u)
{
List<Utilisateur> data = await this.getAllUtilisateurs();
data.Add(u);
await this.SaveAllUtilisateurs(data);
}
public async Task SupprimerUtilisateur(Utilisateur u)
{
List<Utilisateur> 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<Utilisateur> lUtilisateurs = new List<Utilisateur>();
lUtilisateurs = await this.getUtilisateursFromJson(this.EmplacementJson);
await this.saveUtilisateursLocalStorage(lUtilisateurs);
Console.WriteLine("Local storage reset !");
}
public async Task SaveAllUtilisateurs(List<Utilisateur> list)
{
await this.saveUtilisateursLocalStorage(list);
}
public async Task AjouterUtilisateur(Utilisateur u)
{
List<Utilisateur> data = await this.getAllUtilisateurs();
data.Add(u);
await this.SaveAllUtilisateurs(data);
}
public async Task SupprimerUtilisateur(Utilisateur u)
{
List<Utilisateur> 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);

Loading…
Cancel
Save