Login en cours

pull/22/head
lebeaulato 3 months ago
parent c5c2e597ae
commit 6c95137bf8

@ -1,16 +1,20 @@
namespace WF_WebAdmin.Converter using WF_WebAdmin.Model;
namespace WF_WebAdmin.Converter
{ {
public class UserDTO public class UserDTO
{ {
public int Id { get; set; }
public string Image { get; set; } public string Image { get; set; }
public string Name { get; set; } public string Name { get; set; }
public string Email { get; set; } public string Email { get; set; }
public DateTime DateCreation { 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<Commentary> Comments { get; set; }
public UserDTO(string image, string name, string email, DateTime dateCreation)
{ {
this.Id = id;
this.Image = image; this.Image = image;
this.Name = name; this.Name = name;
this.Email = email; this.Email = email;

@ -6,13 +6,13 @@ namespace WF_WebAdmin.Converter
{ {
public User UserToDTO(UserDTO u) 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; return user;
} }
public UserDTO DTOToUser(User u) 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; return user;
} }
} }

@ -2,20 +2,24 @@
{ {
public class User public class User
{ {
public int Id { get; set; }
public string Image { get; set; } public string Image { get; set; }
public string Name { get; set; } public string Name { get; set; }
public string Email { get; set; } public string Email { get; set; }
public DateTime DateCreation { 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<Commentary> Comments { get; set; }
public User(string image, string name, string email, DateTime dateCreation, bool isAdmin)
{ {
this.Id = id;
this.Image = image; this.Image = image;
this.Name = name; this.Name = name;
this.Email = email; this.Email = email;
this.DateCreation = dateCreation; this.DateCreation = dateCreation;
IsAdmin = isAdmin;
} }
public User() { }
} }
} }

@ -0,0 +1,28 @@
namespace WF_WebAdmin.Model
{
public class UserLogin
{
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 List<Commentary> Comments { get; set; }
public string Mdp { get; set; }
public UserLogin(string image, string name, string email, DateTime dateCreation, bool isAdmin, string mdp)
{
this.Image = image;
this.Name = name;
this.Email = email;
this.DateCreation = dateCreation;
this.IsAdmin = isAdmin;
this.Mdp = mdp;
}
public UserLogin() { }
}
}

@ -16,7 +16,6 @@ else
{ {
<div class="userDiv"> <div class="userDiv">
<img class="imgProfil" src="@user.Image" /> <img class="imgProfil" src="@user.Image" />
<p class="idUser"><strong>Identifiant d'utilisateur :</strong> @user.Id</p>
@if (user.IsAdmin) @if (user.IsAdmin)
{ {
<p class="pseudo"><strong>Nom d'utilisateur :</strong> @user.Name <strong>(Administrateur)</strong></p> <p class="pseudo"><strong>Nom d'utilisateur :</strong> @user.Name <strong>(Administrateur)</strong></p>
@ -39,7 +38,7 @@ else
} }
else else
{ {
<p>Aucun commentaire sur le site</p> <p><i>Aucun commentaire sur le site</i></p>
} }
<button id="DeleteButton" @onclick="() => ShowConfirmation(user)">Supprimer l'utilisateur</button> <button id="DeleteButton" @onclick="() => ShowConfirmation(user)">Supprimer l'utilisateur</button>

@ -40,7 +40,7 @@ namespace WF_WebAdmin.Pages
{ {
if (userToDelete != null) if (userToDelete != null)
{ {
users.RemoveAll(u => u.Id == userToDelete.Id); users.RemoveAll(u => u.Name == userToDelete.Name);
ClosePopup(); ClosePopup();
} }
} }

@ -2,27 +2,28 @@
<h1>▶ Connexion ◀</h1> <h1>▶ Connexion ◀</h1>
<div class="login"> <div class="login">
@* <form method="post" action="{{ racine }}/validlogin"> *@ <EditForm Model="userLogin" OnValidSubmit="validlogin">
<p> <strong>Identifiant *</strong></p> <DataAnnotationsValidator />
<input type="text" class="connexion" name="pseudo" id="pseudo" placeholder="Entrez votre pseudo" required /> <ValidationSummary />
<p> <strong> Mot de passe *</strong></p>
<input type="password" class="connexion" name="mdp" id="mdp" placeholder="Entrez votre mdp" required />
<label for="name"><strong>Identifiant *</strong></label>
<InputText @bind-Value="userLogin.Name" id="name" placeholder="Entrez votre pseudo" class="connexion" required />
<label for="mdp"><strong>Mot de passe*</strong></label>
@* <p> <strong> Mot de passe *</strong></p>
<input type="password" class="connexion" name="mdp" id="mdp" placeholder="Entrez votre mdp" required /> *@
<div class="buttonSubmitDiv"> <div class="buttonSubmitDiv">
<button class="buttonSudmite">Se Connecter</button> <button class="buttonSudmite"type="submit">Se Connecter</button>
</div> </div>
<p>@TestConnexion</p>
@* </form> *@ </EditForm>
</div> </div>
@code { @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
}
} }

@ -8,6 +8,45 @@ namespace WF_WebAdmin.Pages
{ {
public partial class Login public partial class Login
{ {
private UserLogin userLogin = new UserLogin();
private string TestConnexion = "Pas connexion";
private List<UserLogin> usersConnexion;
[Inject]
public HttpClient Http { get; set; }
[Inject]
public NavigationManager NavigationManager { get; set; }
protected override async Task OnInitializedAsync()
{
usersConnexion = await Http.GetFromJsonAsync<List<UserLogin>>($"{NavigationManager.BaseUri}fake-dataUserLogin.json");
}
public void validlogin()
{
if (!string.IsNullOrEmpty(userLogin.Name))
{
foreach (var user in usersConnexion)
{
if(userLogin.Name == user.Name)
{
if(user.IsAdmin)
{
TestConnexion = $"Connecté en tant que {user.Name}";
}
else
{
TestConnexion = "Connexion échouée, pas admin";
}
}
}
}
}
} }
} }

@ -7,10 +7,10 @@
{ {
<p>Chargement des citations...</p> <p>Chargement des citations...</p>
} }
else if (quotes.Count == 0) @* else if (quotes.Count == 0)
{ {
<p>Aucune citation en attente de validation.</p> <p>Aucune citation en attente de validation.</p>
} } *@
else else
{ {
<p>Citations en attente de validation :</p> <p>Citations en attente de validation :</p>
@ -28,8 +28,8 @@ else
<p><strong>Date de source :</strong> @quote.DateSrc.ToShortDateString()</p> <p><strong>Date de source :</strong> @quote.DateSrc.ToShortDateString()</p>
<p><strong>Utilisateur :</strong> @quote.UserProposition</p> <p><strong>Utilisateur :</strong> @quote.UserProposition</p>
<button @onclick="() => ValiderQuote(quote.Id)">Valider</button> @* <button @onclick="() => ValiderQuote(quote.Id)">Valider</button>
<button @onclick="() => RejeterQuote(quote.Id)">Rejeter</button> <button @onclick="() => RejeterQuote(quote.Id)">Rejeter</button> *@
</div> </div>
} }
} }

@ -9,10 +9,22 @@
<main> <main>
<div class="top-row px-4"> <div class="top-row px-4">
<a href="https://docs.microsoft.com/aspnet/" target="_blank">About</a> @if(usersConnexion != null)
{
<img class="imageProfil" src="@usersConnexion[2].Image" />
}
</div> </div>
<article class="content px-4"> <article class="content px-4">
@Body @Body
</article> </article>
</main> </main>
</div> </div>
<style>
.imageProfil{
height:auto;
width : 30px;
border-radius:45%;
}
</style>

@ -0,0 +1,21 @@
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Mvc;
using WF_WebAdmin.Model;
namespace WF_WebAdmin.Shared
{
public partial class MainLayout
{
private List<User> usersConnexion;
[Inject]
public HttpClient Http { get; set; }
[Inject]
public NavigationManager NavigationManager { get; set; }
protected override async Task OnInitializedAsync()
{
usersConnexion = await Http.GetFromJsonAsync<List<User>>($"{NavigationManager.BaseUri}fake-dataUsers.json");
}
}
}

@ -1,4 +1,5 @@
@import url('open-iconic/font/css/open-iconic-bootstrap.min.css'); @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 { html, body {
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
@ -132,13 +133,13 @@ h1 {
text-align: center; text-align: center;
font-size: 32px; font-size: 32px;
margin-top: 10%; margin-top: 10%;
font-family: "Roboto", serif;
} }
p { p {
margin-top: 6%;
margin-bottom: 2%; margin-bottom: 2%;
font-size: 20px; font-size: 20px;
font-family: "Lemon", serif; font-family: "Roboto", serif;
} }
.login { .login {
@ -160,6 +161,7 @@ p {
width: 50%; width: 50%;
font-size: 1.25em; font-size: 1.25em;
background-color: white; background-color: white;
font-family: "Roboto", serif;
} }
.connexion { .connexion {

@ -0,0 +1,155 @@
[
{
"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",
"Email": "admin@gmail.com",
"DateCreation": "2024-12-12",
"IsAdmin": true,
"Mdp" : "test"
},
{
"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
},
{
"Id": 3,
"Image": "https://tse4.mm.bing.net/th/id/OIP.XNQPKwc1OUfvnSO9MsxDYgHaE7?w=202&h=180&c=7&r=0&o=5&pid=1.7",
"Name": "testeur",
"Email": "testeur@gmail.com",
"DateCreation": "2024-08-02",
"IsAdmin": false,
"Comments": [
{
"Text": "Premier test effectué, tout semble OK.",
"DateCreation": "2024-08-02"
}
]
},
{
"Id": 4,
"Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137&h=195&c=7&r=0&o=5&pid=1.7",
"Name": "dev",
"Email": "dev@gmail.com",
"DateCreation": "2024-10-10",
"IsAdmin": false
},
{
"Id": 5,
"Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137&h=195&c=7&r=0&o=5&pid=1.7",
"Name": "jean_doe",
"Email": "jean.doe@gmail.com",
"DateCreation": "2024-06-25",
"IsAdmin": false,
"Comments": [
{
"Text": "Utilisateur très actif, peut être un peu trop intrusif.",
"DateCreation": "2024-06-25"
}
]
},
{
"Id": 6,
"Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137&h=195&c=7&r=0&o=5&pid=1.7",
"Name": "jane_smith",
"Email": "jane.smith@gmail.com",
"DateCreation": "2024-07-15",
"IsAdmin": false
},
{
"Id": 7,
"Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137&h=195&c=7&r=0&o=5&pid=1.7",
"Name": "admin_joe",
"Email": "admin.joe@gmail.com",
"DateCreation": "2024-05-30",
"IsAdmin": true
},
{
"Id": 8,
"Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137&h=195&c=7&r=0&o=5&pid=1.7",
"Name": "dev_anna",
"Email": "dev.anna@gmail.com",
"DateCreation": "2024-09-05",
"IsAdmin": false
},
{
"Id": 9,
"Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137&h=195&c=7&r=0&o=5&pid=1.7",
"Name": "support_mark",
"Email": "support.mark@gmail.com",
"DateCreation": "2024-11-20",
"IsAdmin": false,
"Comments": [
{
"Text": "Support rapide et efficace, mais manquant un peu de détails.",
"DateCreation": "2024-11-20"
}
]
},
{
"Id": 10,
"Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137&h=195&c=7&r=0&o=5&pid=1.7",
"Name": "dev_susan",
"Email": "dev.susan@gmail.com",
"DateCreation": "2024-08-12",
"IsAdmin": false
},
{
"Id": 11,
"Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137&h=195&c=7&r=0&o=5&pid=1.7",
"Name": "designer_steve",
"Email": "designer.steve@gmail.com",
"DateCreation": "2024-07-01",
"IsAdmin": false,
"Comments": [
{
"Text": "Le design doit être retravaillé pour plus de clarté.",
"DateCreation": "2024-07-01"
}
]
},
{
"Id": 12,
"Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137&h=195&c=7&r=0&o=5&pid=1.7",
"Name": "admin_lucas",
"Email": "admin.lucas@gmail.com",
"DateCreation": "2024-09-22",
"IsAdmin": true
},
{
"Id": 13,
"Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137&h=195&c=7&r=0&o=5&pid=1.7",
"Name": "manager_anna",
"Email": "manager.anna@gmail.com",
"DateCreation": "2024-05-01",
"IsAdmin": false
},
{
"Id": 14,
"Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137&h=195&c=7&r=0&o=5&pid=1.7",
"Name": "developer_mike",
"Email": "developer.mike@gmail.com",
"DateCreation": "2024-11-02",
"IsAdmin": false
},
{
"Id": 15,
"Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137&h=195&c=7&r=0&o=5&pid=1.7",
"Name": "test_user_01",
"Email": "test.user01@gmail.com",
"DateCreation": "2024-06-10",
"IsAdmin": false
},
{
"Id": 16,
"Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137&h=195&c=7&r=0&o=5&pid=1.7",
"Name": "admin_kate",
"Email": "admin.kate@gmail.com",
"DateCreation": "2024-04-16",
"IsAdmin": true
}
]
Loading…
Cancel
Save