Äjouter cache mdp Inscription + hash mdp Inscription

serviceApiJean
Tony Fages 1 year ago
parent b367e07241
commit 3fd412c1eb

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

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

@ -77,11 +77,17 @@
<Field Horizontal> <Field Horizontal>
<FieldLabel ColumnSize="ColumnSize.Is2">Mot de passe</FieldLabel> <FieldLabel ColumnSize="ColumnSize.Is2">Mot de passe</FieldLabel>
<FieldBody ColumnSize="ColumnSize.Is10"> <FieldBody ColumnSize="ColumnSize.Is10">
<TextEdit Placeholder="Entrez votre mot de passe" @bind-Text="@Requete.MotDePasse"> <div class="input-group">
<Feedback> <TextEdit @bind-Text="@Requete.MotDePasse"
<ValidationError /> Type="@(showPassword ? "text" : "password")"
</Feedback> Class="form-control" Placeholder="Mot de passe" />
</TextEdit>
<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> </FieldBody>
</Field> </Field>
</Validation> </Validation>
@ -92,11 +98,17 @@
<Field Horizontal> <Field Horizontal>
<FieldLabel ColumnSize="ColumnSize.Is2">Confirmer le mot de passe</FieldLabel> <FieldLabel ColumnSize="ColumnSize.Is2">Confirmer le mot de passe</FieldLabel>
<FieldBody ColumnSize="ColumnSize.Is10"> <FieldBody ColumnSize="ColumnSize.Is10">
<TextEdit Placeholder="Entrez votre mot de à nouveau" @bind-Text="@Requete.MotDePasseConfirmation"> <div class="input-group">
<Feedback> <TextEdit @bind-Text="@Requete.MotDePasseConfirmation"
<ValidationError /> Type="@(showPasswordConf ? "text" : "password")"
</Feedback> Class="form-control" Placeholder="Confirmez mot de passe" />
</TextEdit>
<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> </FieldBody>
</Field> </Field>
</Validation> </Validation>

@ -20,6 +20,11 @@ namespace VeraxShield.composants.authentification
public String Erreur {get; set; } public String Erreur {get; set; }
public bool showPassword = false;
public bool showPasswordConf = false;
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
this.Requete = new RequeteInscription(); this.Requete = new RequeteInscription();
@ -39,5 +44,15 @@ namespace VeraxShield.composants.authentification
{ {
this.NavigationManager.NavigateTo("/connexion"); 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.composants.formulaires.modeles;
using VeraxShield.modele.utilisateurs; using VeraxShield.modele.utilisateurs;
using VeraxShield.services.UtilisateursDataService; using VeraxShield.services.UtilisateursDataService;
using BCrypt.Net;
public class AuthentificationService : IAuthentificationService public class AuthentificationService : IAuthentificationService
{ {
@ -50,8 +51,14 @@ public class AuthentificationService : IAuthentificationService
public async Task Inscription(RequeteInscription requete) public async Task Inscription(RequeteInscription requete)
{ {
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", await this._utilisateursDataService.AjouterUtilisateur(new Utilisateur(requete.Pseudo, requete.Nom, requete.Prenom, "invite",
requete.MotDePasse, requete.Mail, false)); motDePasseHache, requete.Mail, false));
await this.MajUtilisateurs(); await this.MajUtilisateurs();
} }

Loading…
Cancel
Save