Äjouter cache mdp Inscription + hash mdp Inscription

serviceApiJean
Tony Fages 1 year ago
parent b367e07241
commit 3fd412c1eb

@ -11,6 +11,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
<PackageReference Include="Blazored.LocalStorage" Version="4.4.0" />
<PackageReference Include="Blazorise.Bootstrap" Version="1.4.1" />
<PackageReference Include="Blazorise.Components" Version="1.4.0" />

@ -35,7 +35,7 @@
<div class="input-group">
<TextEdit @bind-Text="@Requete.MotDePasse"
Type="@(showPassword ? "text" : "password")"
Class="form-control" />
Class="form-control" Placeholder="Mot De Passe"/>
<span class="input-group-btn">
<button class="btn btn-default" type="button" @onclick="ToggleShowPassword">

@ -77,11 +77,17 @@
<Field Horizontal>
<FieldLabel ColumnSize="ColumnSize.Is2">Mot de passe</FieldLabel>
<FieldBody ColumnSize="ColumnSize.Is10">
<TextEdit Placeholder="Entrez votre mot de passe" @bind-Text="@Requete.MotDePasse">
<Feedback>
<ValidationError />
</Feedback>
</TextEdit>
<div class="input-group">
<TextEdit @bind-Text="@Requete.MotDePasse"
Type="@(showPassword ? "text" : "password")"
Class="form-control" Placeholder="Mot de passe" />
<span class="input-group-btn">
<button class="btn btn-default" type="button" @onclick="ToggleShowPassword">
<i class="@(showPassword ? "fa fa-eye-slash" : "fa fa-eye")"></i>
</button>
</span>
</div>
</FieldBody>
</Field>
</Validation>
@ -92,11 +98,17 @@
<Field Horizontal>
<FieldLabel ColumnSize="ColumnSize.Is2">Confirmer le mot de passe</FieldLabel>
<FieldBody ColumnSize="ColumnSize.Is10">
<TextEdit Placeholder="Entrez votre mot de à nouveau" @bind-Text="@Requete.MotDePasseConfirmation">
<Feedback>
<ValidationError />
</Feedback>
</TextEdit>
<div class="input-group">
<TextEdit @bind-Text="@Requete.MotDePasseConfirmation"
Type="@(showPasswordConf ? "text" : "password")"
Class="form-control" Placeholder="Confirmez mot de passe" />
<span class="input-group-btn">
<button class="btn btn-default" type="button" @onclick="ToggleShowPasswordConf">
<i class="@(showPasswordConf ? "fa fa-eye-slash" : "fa fa-eye")"></i>
</button>
</span>
</div>
</FieldBody>
</Field>
</Validation>

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

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

Loading…
Cancel
Save