diff --git a/WF-WebAdmin/WF-WebAdmin/Converter/UserDTO.cs b/WF-WebAdmin/WF-WebAdmin/Converter/UserDTO.cs index e1b64da..53a6032 100644 --- a/WF-WebAdmin/WF-WebAdmin/Converter/UserDTO.cs +++ b/WF-WebAdmin/WF-WebAdmin/Converter/UserDTO.cs @@ -1,16 +1,20 @@ -namespace WF_WebAdmin.Converter +using WF_WebAdmin.Model; + +namespace WF_WebAdmin.Converter { public class UserDTO { - public int Id { get; set; } public string Image { get; set; } public string Name { get; set; } public string Email { get; set; } public DateTime DateCreation { get; set; } - public UserDTO(int id, string image, string name, string email, DateTime dateCreation) + public Boolean IsAdmin { get; set; } + public List Comments { get; set; } + + public UserDTO(string image, string name, string email, DateTime dateCreation) { - this.Id = id; + this.Image = image; this.Name = name; this.Email = email; diff --git a/WF-WebAdmin/WF-WebAdmin/Converter/UserExtension.cs b/WF-WebAdmin/WF-WebAdmin/Converter/UserExtension.cs index 4ff0937..ebcf0e4 100644 --- a/WF-WebAdmin/WF-WebAdmin/Converter/UserExtension.cs +++ b/WF-WebAdmin/WF-WebAdmin/Converter/UserExtension.cs @@ -6,13 +6,13 @@ namespace WF_WebAdmin.Converter { public User UserToDTO(UserDTO u) { - User user = new User(u.Id, u.Image, u.Name, u.Email, u.DateCreation); + User user = new User(u.Image, u.Name, u.Email, u.DateCreation,u.IsAdmin); return user; } public UserDTO DTOToUser(User u) { - UserDTO user = new UserDTO(u.Id, u.Image, u.Name, u.Email, u.DateCreation); + UserDTO user = new UserDTO(u.Image, u.Name, u.Email, u.DateCreation); return user; } } diff --git a/WF-WebAdmin/WF-WebAdmin/Model/User.cs b/WF-WebAdmin/WF-WebAdmin/Model/User.cs index 7598733..599ee8e 100644 --- a/WF-WebAdmin/WF-WebAdmin/Model/User.cs +++ b/WF-WebAdmin/WF-WebAdmin/Model/User.cs @@ -2,20 +2,24 @@ { public class User { - public int Id { get; set; } public string Image { get; set; } public string Name { get; set; } public string Email { get; set; } public DateTime DateCreation { get; set; } + public Boolean IsAdmin { get; set; } - public User(int id, string image, string name, string email, DateTime dateCreation) + public List Comments { get; set; } + + public User(string image, string name, string email, DateTime dateCreation, bool isAdmin) { - this.Id = id; this.Image = image; this.Name = name; this.Email = email; this.DateCreation = dateCreation; + IsAdmin = isAdmin; } + + public User() { } } } diff --git a/WF-WebAdmin/WF-WebAdmin/Model/UserLogin.cs b/WF-WebAdmin/WF-WebAdmin/Model/UserLogin.cs new file mode 100644 index 0000000..a2e9bb7 --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Model/UserLogin.cs @@ -0,0 +1,24 @@ +namespace WF_WebAdmin.Model +{ + public class UserLogin + { + public int Id { get; set; } + public string Image { get; set; } + public string Name { get; set; } + + public Boolean IsAdmin { get; set; } + + public string Mdp { get; set; } + + public UserLogin(int id,string image, string name, bool isAdmin, string mdp) + { + Id = id; + this.Image = image; + this.Name = name; + this.IsAdmin = isAdmin; + this.Mdp = mdp; + } + + public UserLogin() { } + } +} diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor index 0b0ec58..c0c86ce 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor +++ b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor @@ -16,7 +16,6 @@ else {
-

Identifiant d'utilisateur : @user.Id

@if (user.IsAdmin) {

Nom d'utilisateur : @user.Name (Administrateur)

@@ -39,7 +38,7 @@ else } else { -

Aucun commentaire sur le site

+

Aucun commentaire sur le site

} diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs index 9d2a681..b14bdec 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs +++ b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs @@ -40,7 +40,7 @@ namespace WF_WebAdmin.Pages { if (userToDelete != null) { - users.RemoveAll(u => u.Id == userToDelete.Id); + users.RemoveAll(u => u.Name == userToDelete.Name); ClosePopup(); } } diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/Login.razor b/WF-WebAdmin/WF-WebAdmin/Pages/Login.razor index 7fc91e3..908ce74 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/Login.razor +++ b/WF-WebAdmin/WF-WebAdmin/Pages/Login.razor @@ -1,28 +1,29 @@ @page "/" +@using WF_WebAdmin.Model +@inject UserLogin uLogin

▶ Connexion ◀

@code { - private void ShowFullSite() - { - // Code pour afficher l'ensemble du menu - // Cela peut être un appel à une méthode ou un service qui change l'état de la visibilité du menu - } + } \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/Login.razor.cs b/WF-WebAdmin/WF-WebAdmin/Pages/Login.razor.cs index 0f288f5..6f6c59f 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/Login.razor.cs +++ b/WF-WebAdmin/WF-WebAdmin/Pages/Login.razor.cs @@ -8,6 +8,51 @@ namespace WF_WebAdmin.Pages { public partial class Login { + private UserLogin userLogin = new UserLogin(); + private string ErrorConnexion; + + private List usersConnexion; + [Inject] + public HttpClient Http { get; set; } + + [Inject] + public NavigationManager NavigationManager { get; set; } + + protected override async Task OnInitializedAsync() + { + usersConnexion = await Http.GetFromJsonAsync>($"{NavigationManager.BaseUri}fake-dataUsers.json"); + } + + + public void validlogin() + { + if (!string.IsNullOrEmpty(userLogin.Name) || !string.IsNullOrEmpty(userLogin.Mdp)) + { + foreach (var user in usersConnexion) + { + if(userLogin.Name == user.Name && userLogin.Mdp == user.Mdp) + { + if(user.IsAdmin) + { + ErrorConnexion = $"Connecté en tant que {user.Name} (Ca doit disparaitre dans le futur)"; + uLogin.Id = user.Id; + break; + } + else + { + ErrorConnexion = "Connexion échouée, le nom ou le mot de passe sont incorrectes"; + } + + } + else + { + ErrorConnexion = "Connexion échouée, le nom ou le mot de passe sont incorrectes"; + } + } + + } + + } } } \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/ValidQuote.razor b/WF-WebAdmin/WF-WebAdmin/Pages/ValidQuote.razor index 57f8ecc..0f7606d 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/ValidQuote.razor +++ b/WF-WebAdmin/WF-WebAdmin/Pages/ValidQuote.razor @@ -7,10 +7,10 @@ {

Chargement des citations...

} -else if (quotes.Count == 0) +@* else if (quotes.Count == 0) {

Aucune citation en attente de validation.

-} +} *@ else {

Citations en attente de validation :

@@ -28,8 +28,8 @@ else

Date de source : @quote.DateSrc.ToShortDateString()

Utilisateur : @quote.UserProposition

- - + @* + *@
} } diff --git a/WF-WebAdmin/WF-WebAdmin/Program.cs b/WF-WebAdmin/WF-WebAdmin/Program.cs index 7381387..ed541e6 100644 --- a/WF-WebAdmin/WF-WebAdmin/Program.cs +++ b/WF-WebAdmin/WF-WebAdmin/Program.cs @@ -4,6 +4,7 @@ using Blazorise.Icons.FontAwesome; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Web; using WF_WebAdmin.Data; +using WF_WebAdmin.Model; var builder = WebApplication.CreateBuilder(args); @@ -13,7 +14,7 @@ builder.Services.AddServerSideBlazor(); builder.Services.AddSingleton(); builder.Services.AddHttpClient(); - +builder.Services.AddSingleton(); builder.Services .AddBlazorise() diff --git a/WF-WebAdmin/WF-WebAdmin/Shared/MainLayout.razor b/WF-WebAdmin/WF-WebAdmin/Shared/MainLayout.razor index 2c7f47e..942b447 100644 --- a/WF-WebAdmin/WF-WebAdmin/Shared/MainLayout.razor +++ b/WF-WebAdmin/WF-WebAdmin/Shared/MainLayout.razor @@ -1,5 +1,7 @@ -@inherits LayoutComponentBase - +@using WF_WebAdmin.Model +@inherits LayoutComponentBase +@inject UserLogin uLogin + WF-WebAdmin
@@ -8,11 +10,27 @@
-
- About +
+ @if (!string.IsNullOrEmpty(uLogin.Name)) + { + + } + else + { + + }
@Body
+ + diff --git a/WF-WebAdmin/WF-WebAdmin/Shared/MainLayout.razor.cs b/WF-WebAdmin/WF-WebAdmin/Shared/MainLayout.razor.cs new file mode 100644 index 0000000..f7cb295 --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Shared/MainLayout.razor.cs @@ -0,0 +1,25 @@ +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Mvc; +using System; +using WF_WebAdmin.Model; + + +namespace WF_WebAdmin.Shared +{ + public partial class MainLayout + { + //private List usersConnexion; + + //[Inject] + //public HttpClient Http { get; set; } + + //[Inject] + //public NavigationManager NavigationManager { get; set; } + + //protected override async Task OnInitializedAsync() + //{ + + // usersConnexion = await Http.GetFromJsonAsync>($"{NavigationManager.BaseUri}fake-dataUsers.json"); + //} + } +} diff --git a/WF-WebAdmin/WF-WebAdmin/wwwroot/css/site.css b/WF-WebAdmin/WF-WebAdmin/wwwroot/css/site.css index e388634..33c8b06 100644 --- a/WF-WebAdmin/WF-WebAdmin/wwwroot/css/site.css +++ b/WF-WebAdmin/WF-WebAdmin/wwwroot/css/site.css @@ -1,4 +1,5 @@ @import url('open-iconic/font/css/open-iconic-bootstrap.min.css'); +@import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100..900;1,100..900&display=swap'); html, body { font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; @@ -161,13 +162,13 @@ h1 { text-align: center; font-size: 32px; margin-top: 10%; + font-family: "Roboto", serif; } p { - margin-top: 6%; margin-bottom: 2%; font-size: 20px; - font-family: "Lemon", serif; + font-family: "Roboto", serif; } .login { @@ -189,6 +190,7 @@ p { width: 50%; font-size: 1.25em; background-color: white; + font-family: "Roboto", serif; } .connexion { @@ -203,6 +205,11 @@ p { } + +.ErrorMsg { + color: red; +} + table { border-collapse: collapse; width: 100%; diff --git a/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataUserLogin.json b/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataUserLogin.json new file mode 100644 index 0000000..241a266 --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataUserLogin.json @@ -0,0 +1,16 @@ +[ + { + "Id": 1, + "Image": "https://tse4.mm.bing.net/th/id/OIP.fc5TQflh0cbxB1GUeOdk6gHaK8?w=123&h=180&c=7&r=0&o=5&pid=1.7", + "Name": "Admin", + "IsAdmin": true, + "Mdp" : "passwd" + }, + { + "Id": 2, + "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137&h=195&c=7&r=0&o=5&pid=1.7", + "Name": "exploit", + "IsAdmin": false, + "Mdp": "passwd" + } +] \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataUsers.json b/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataUsers.json index ec07099..d995d42 100644 --- a/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataUsers.json +++ b/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataUsers.json @@ -5,25 +5,27 @@ "Name": "Admin", "Email": "admin@gmail.com", "DateCreation": "2024-12-12", - "IsAdmin": true, - "Comments": [ - { - "Text": "Commentaire 1", - "DateCreation": "2024-12-12" - }, - { - "Text": "Commentaire 2", - "DateCreation": "2024-11-12" - } - ] - }, - { + "IsAdmin": true, + "Comments": [ + { + "Text": "Commentaire 1", + "DateCreation": "2024-12-12" + }, + { + "Text": "Commentaire 2", + "DateCreation": "2024-11-12" + } + ], + "Mdp": "passwd" + }, + { "Id": 2, "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137&h=195&c=7&r=0&o=5&pid=1.7", "Name": "exploit", "Email": "exploit@gmail.com", "DateCreation": "2024-11-12", - "IsAdmin": true + "IsAdmin": false, + "Mdp": "passwd" }, { "Id": 3,