diff --git a/VeraxShield/VeraxShield/composants/affichages/utilisateurs/DatagridUtilisateurs.razor b/VeraxShield/VeraxShield/composants/affichages/utilisateurs/DatagridUtilisateurs.razor index 6181c1f..929d2c5 100644 --- a/VeraxShield/VeraxShield/composants/affichages/utilisateurs/DatagridUtilisateurs.razor +++ b/VeraxShield/VeraxShield/composants/affichages/utilisateurs/DatagridUtilisateurs.razor @@ -19,17 +19,26 @@ - + + + + @if (context.IsBan) { + Ban + } else { + Valide + } + + + - + + - - diff --git a/VeraxShield/VeraxShield/composants/authentification/FormulaireConnexion.razor b/VeraxShield/VeraxShield/composants/authentification/FormulaireConnexion.razor index bc6a6b0..cdef417 100644 --- a/VeraxShield/VeraxShield/composants/authentification/FormulaireConnexion.razor +++ b/VeraxShield/VeraxShield/composants/authentification/FormulaireConnexion.razor @@ -17,7 +17,7 @@ Pseudo - + diff --git a/VeraxShield/VeraxShield/composants/authentification/FormulaireInscription.razor b/VeraxShield/VeraxShield/composants/authentification/FormulaireInscription.razor new file mode 100644 index 0000000..e69de29 diff --git a/VeraxShield/VeraxShield/composants/authentification/FormulaireInscription.razor.cs b/VeraxShield/VeraxShield/composants/authentification/FormulaireInscription.razor.cs new file mode 100644 index 0000000..74d62f7 --- /dev/null +++ b/VeraxShield/VeraxShield/composants/authentification/FormulaireInscription.razor.cs @@ -0,0 +1,7 @@ +namespace VeraxShield.composants.authentification +{ + public partial class FormulaireConnexion + { + + } +} \ No newline at end of file diff --git a/VeraxShield/VeraxShield/composants/authentification/modele/RequeteConnexion.cs b/VeraxShield/VeraxShield/composants/authentification/modele/RequeteConnexion.cs index ee522ca..47a7c8a 100644 --- a/VeraxShield/VeraxShield/composants/authentification/modele/RequeteConnexion.cs +++ b/VeraxShield/VeraxShield/composants/authentification/modele/RequeteConnexion.cs @@ -8,6 +8,6 @@ namespace VeraxShield.composants.formulaires.modeles public string MotDePasse { get; set; } [Required(ErrorMessage="le champ est obligatoire !")] - public string Nom { get; set; } + public string Pseudo { get; set; } } } diff --git a/VeraxShield/VeraxShield/composants/authentification/modele/RequeteInscription.cs b/VeraxShield/VeraxShield/composants/authentification/modele/RequeteInscription.cs index 0a80f0d..9d99d90 100644 --- a/VeraxShield/VeraxShield/composants/authentification/modele/RequeteInscription.cs +++ b/VeraxShield/VeraxShield/composants/authentification/modele/RequeteInscription.cs @@ -13,5 +13,14 @@ namespace VeraxShield.composants.formulaires.modeles [Required] public string Nom { get; set; } + + [Required] + public string Prenom {get; set;} + + [Required] + public string Pseudo { get; set; } + + [Required] + public string Mail { get; set;} } } diff --git a/VeraxShield/VeraxShield/factories/UtilisateursFactory.cs b/VeraxShield/VeraxShield/factories/UtilisateursFactory.cs index dc5b781..57537ba 100644 --- a/VeraxShield/VeraxShield/factories/UtilisateursFactory.cs +++ b/VeraxShield/VeraxShield/factories/UtilisateursFactory.cs @@ -32,5 +32,16 @@ namespace VeraxShield.factories return temp; } + + public static Utilisateur toUtilisateur(AppUtilisateur appUtilisateur) + { + return new Utilisateur(appUtilisateur.Pseudo, appUtilisateur.Nom, appUtilisateur.Prenom, + appUtilisateur.Roles[0], appUtilisateur.MotDePasse, appUtilisateur.Mail, false); + } + + public static AppUtilisateur toAppUtilisateur(Utilisateur u) + { + return new AppUtilisateur(u.Pseudo, u.Nom, u.Prenom, u.Mail, u.Mdp, u.Role); + } } } diff --git a/VeraxShield/VeraxShield/modele/authentification/AppUtilisateur.cs b/VeraxShield/VeraxShield/modele/authentification/AppUtilisateur.cs index 4da82d2..662f348 100644 --- a/VeraxShield/VeraxShield/modele/authentification/AppUtilisateur.cs +++ b/VeraxShield/VeraxShield/modele/authentification/AppUtilisateur.cs @@ -2,11 +2,18 @@ public class AppUtilisateur { public string MotDePasse { get; set; } public List Roles { get; set; } + public string Pseudo { get; set; } + public string Prenom { get; set; } public string Nom { get; set; } + public string Mail { get; set; } - public AppUtilisateur(string nom, string mdp, String premierRole) + + public AppUtilisateur(string pseudo,string nom, string prenom, string mail, string mdp, String premierRole) { this.MotDePasse = mdp; + this.Pseudo = pseudo; + this.Mail = mail; + this.Prenom = prenom; this.Nom = nom; this.Roles = new List(); diff --git a/VeraxShield/VeraxShield/modele/authentification/UtilisateurCourant.cs b/VeraxShield/VeraxShield/modele/authentification/UtilisateurCourant.cs index 9cb4e08..5a1dd43 100644 --- a/VeraxShield/VeraxShield/modele/authentification/UtilisateurCourant.cs +++ b/VeraxShield/VeraxShield/modele/authentification/UtilisateurCourant.cs @@ -2,5 +2,5 @@ public class UtilisateurCourant { public Dictionary Claims { get; set; } public bool EstAuthentifie { get; set; } - public string Nom { get; set; } + public string Pseudo { get; set; } } \ No newline at end of file diff --git a/VeraxShield/VeraxShield/services/authentificationService/AuthentificationService.cs b/VeraxShield/VeraxShield/services/authentificationService/AuthentificationService.cs index ea18e2f..ea4604e 100644 --- a/VeraxShield/VeraxShield/services/authentificationService/AuthentificationService.cs +++ b/VeraxShield/VeraxShield/services/authentificationService/AuthentificationService.cs @@ -1,22 +1,25 @@ using System.Security.Claims; using VeraxShield.composants.formulaires.modeles; +using VeraxShield.services.UtilisateursDataService; public class AuthentificationService : IAuthentificationService { private static readonly List utilisateursApplication; + private static IUtilisateursDataService _utilisateursDataService { get; set; } static AuthentificationService() { + utilisateursApplication = new List(); - utilisateursApplication.Add(new AppUtilisateur("Admin", "Admin", "admin")); + utilisateursApplication.Add(new AppUtilisateur("Admin", "Compte", "Admin", "compte@admin.fr", "Admin", "admin")); } public void Connexion(RequeteConnexion requete) { - var utilisateur = utilisateursApplication.FirstOrDefault(w => w.Nom == requete.Nom && w.MotDePasse == requete.MotDePasse); + var utilisateur = utilisateursApplication.FirstOrDefault(w => w.Pseudo == requete.Pseudo && w.MotDePasse == requete.MotDePasse); if (utilisateur == null) { @@ -26,7 +29,7 @@ public class AuthentificationService : IAuthentificationService public UtilisateurCourant GetUtilisateur(string nom) { - var utilisateur = utilisateursApplication.FirstOrDefault(w => w.Nom == nom); + var utilisateur = utilisateursApplication.FirstOrDefault(w => w.Pseudo == nom); if (utilisateur == null) { @@ -39,13 +42,14 @@ public class AuthentificationService : IAuthentificationService return new UtilisateurCourant { EstAuthentifie = true, - Nom = utilisateur.Nom, + Pseudo = utilisateur.Pseudo, Claims = claims.ToDictionary(c => c.Type, c => c.Value) }; } public void Inscription(RequeteInscription requete) { - utilisateursApplication.Add(new AppUtilisateur(requete.Nom, requete.MotDePasse, "invite" )); + utilisateursApplication.Add(new AppUtilisateur(requete.Pseudo, requete.Nom, requete.Prenom, + requete.Mail, requete.MotDePasse, "invite")); } } \ No newline at end of file diff --git a/VeraxShield/VeraxShield/services/authentificationService/DonneurEtat.cs b/VeraxShield/VeraxShield/services/authentificationService/DonneurEtat.cs index bb0af8a..e238d32 100644 --- a/VeraxShield/VeraxShield/services/authentificationService/DonneurEtat.cs +++ b/VeraxShield/VeraxShield/services/authentificationService/DonneurEtat.cs @@ -22,7 +22,7 @@ public class DonneurEtat : AuthenticationStateProvider if (userInfo.EstAuthentifie) { - var claims = new[] { new Claim(ClaimTypes.Name, this._utilisateurCourant.Nom) }.Concat(this._utilisateurCourant.Claims.Select(c => new Claim(c.Key, c.Value))); + var claims = new[] { new Claim(ClaimTypes.Name, this._utilisateurCourant.Pseudo) }.Concat(this._utilisateurCourant.Claims.Select(c => new Claim(c.Key, c.Value))); identite = new ClaimsIdentity(claims, "Server authentication"); } } @@ -49,7 +49,7 @@ public class DonneurEtat : AuthenticationStateProvider this._serviceAuthentification.Connexion(requete); // No error - Login the user - var user = this._serviceAuthentification.GetUtilisateur(requete.Nom); + var user = this._serviceAuthentification.GetUtilisateur(requete.Pseudo); this._utilisateurCourant = user; NotifyAuthenticationStateChanged(GetAuthenticationStateAsync());