From 3fd412c1ebf7de727ed8f3184fa85952c7746a45 Mon Sep 17 00:00:00 2001 From: Tony Date: Sat, 20 Jan 2024 11:00:54 +0100 Subject: [PATCH] =?UTF-8?q?=C3=84jouter=20cache=20mdp=20Inscription=20+=20?= =?UTF-8?q?hash=20mdp=20Inscription?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VeraxShield/VeraxShield/VeraxShield.csproj | 1 + .../FormulaireConnexion.razor | 2 +- .../FormulaireInscription.razor | 32 +++++++++++++------ .../FormulaireInscription.razor.cs | 15 +++++++++ .../AuthentificationService.cs | 11 +++++-- 5 files changed, 48 insertions(+), 13 deletions(-) diff --git a/VeraxShield/VeraxShield/VeraxShield.csproj b/VeraxShield/VeraxShield/VeraxShield.csproj index 9b939c3..126f5a2 100644 --- a/VeraxShield/VeraxShield/VeraxShield.csproj +++ b/VeraxShield/VeraxShield/VeraxShield.csproj @@ -11,6 +11,7 @@ + diff --git a/VeraxShield/VeraxShield/composants/authentification/FormulaireConnexion.razor b/VeraxShield/VeraxShield/composants/authentification/FormulaireConnexion.razor index cb2782c..575797e 100644 --- a/VeraxShield/VeraxShield/composants/authentification/FormulaireConnexion.razor +++ b/VeraxShield/VeraxShield/composants/authentification/FormulaireConnexion.razor @@ -35,7 +35,7 @@
+ Class="form-control" Placeholder="Mot De Passe"/> + +
@@ -92,11 +98,17 @@ Confirmer le mot de passe - - - - - +
+ + + + + +
diff --git a/VeraxShield/VeraxShield/composants/authentification/FormulaireInscription.razor.cs b/VeraxShield/VeraxShield/composants/authentification/FormulaireInscription.razor.cs index 61bfe4d..908f091 100644 --- a/VeraxShield/VeraxShield/composants/authentification/FormulaireInscription.razor.cs +++ b/VeraxShield/VeraxShield/composants/authentification/FormulaireInscription.razor.cs @@ -20,6 +20,11 @@ namespace VeraxShield.composants.authentification public String Erreur {get; set; } + + + public bool showPassword = false; + public bool showPasswordConf = false; + protected override async Task OnInitializedAsync() { this.Requete = new RequeteInscription(); @@ -39,5 +44,15 @@ namespace VeraxShield.composants.authentification { this.NavigationManager.NavigateTo("/connexion"); } + + private void ToggleShowPassword() + { + showPassword = !showPassword; + } + + private void ToggleShowPasswordConf() + { + showPasswordConf = !showPasswordConf; + } } } \ No newline at end of file diff --git a/VeraxShield/VeraxShield/services/authentificationService/AuthentificationService.cs b/VeraxShield/VeraxShield/services/authentificationService/AuthentificationService.cs index 5dcae23..61656ff 100644 --- a/VeraxShield/VeraxShield/services/authentificationService/AuthentificationService.cs +++ b/VeraxShield/VeraxShield/services/authentificationService/AuthentificationService.cs @@ -3,6 +3,7 @@ using System.Security.Claims; using VeraxShield.composants.formulaires.modeles; using VeraxShield.modele.utilisateurs; using VeraxShield.services.UtilisateursDataService; +using BCrypt.Net; public class AuthentificationService : IAuthentificationService { @@ -50,8 +51,14 @@ public class AuthentificationService : IAuthentificationService public async Task Inscription(RequeteInscription requete) { - await this._utilisateursDataService.AjouterUtilisateur(new Utilisateur(requete.Pseudo, requete.Nom, requete.Prenom, "invite", - requete.MotDePasse, requete.Mail, false)); + + var motDePasseClair = requete.MotDePasse; + + // Hach du mot de passe + var motDePasseHache = BCrypt.Net.BCrypt.HashPassword(motDePasseClair); + + await this._utilisateursDataService.AjouterUtilisateur(new Utilisateur(requete.Pseudo, requete.Nom, requete.Prenom, "invite", + motDePasseHache, requete.Mail, false)); await this.MajUtilisateurs(); }