From d5fe0df39736419ff947f26dd818e9c4cab19e20 Mon Sep 17 00:00:00 2001 From: rahassou Date: Sat, 17 Dec 2022 09:21:51 +0100 Subject: [PATCH] Connexion et inscription marche --- src/CraftSharp/Models/ConnexionModel.cs | 2 +- src/CraftSharp/Models/InscriptionModel.cs | 9 ++---- src/CraftSharp/Pages/Connexion.razor | 4 +-- src/CraftSharp/Pages/Index.razor | 23 ++++++++++++++- src/CraftSharp/Pages/Inscription.razor | 9 +++--- src/CraftSharp/Pages/Inscription.razor.cs | 10 ++----- src/CraftSharp/Shared/HeaderLayout.razor | 1 + src/CraftSharp/Shared/HeaderLayout.razor.cs | 27 +++++++++++++++++- src/CraftSharp/Shared/InscriptionLayout.razor | 1 - .../Shared/InscriptionLayout.razor.cs | 5 +--- .../Shared/InscriptionLayout.razor.css | 13 ++++++--- src/CraftSharp/_Imports.razor | 3 +- .../wwwroot/{font => fonts}/Minecraft.ttf | Bin src/CraftSharp/wwwroot/fonts/Minecraft.zip | Bin 0 -> 4717 bytes 14 files changed, 74 insertions(+), 33 deletions(-) rename src/CraftSharp/wwwroot/{font => fonts}/Minecraft.ttf (100%) create mode 100644 src/CraftSharp/wwwroot/fonts/Minecraft.zip diff --git a/src/CraftSharp/Models/ConnexionModel.cs b/src/CraftSharp/Models/ConnexionModel.cs index 91115fc..bd4dd73 100644 --- a/src/CraftSharp/Models/ConnexionModel.cs +++ b/src/CraftSharp/Models/ConnexionModel.cs @@ -9,7 +9,7 @@ namespace CraftSharp.Models public string? UserName { get; set; } [Required(ErrorMessage = "Le mot de passe est obligatoire.")] - [MinLength(6, ErrorMessage = "Le mot de passe est trop court")] + [MinLength(4, ErrorMessage = "Le mot de passe est trop court")] public string? Password { get; set; } } } diff --git a/src/CraftSharp/Models/InscriptionModel.cs b/src/CraftSharp/Models/InscriptionModel.cs index 561be78..65b9f6f 100644 --- a/src/CraftSharp/Models/InscriptionModel.cs +++ b/src/CraftSharp/Models/InscriptionModel.cs @@ -6,15 +6,12 @@ namespace CraftSharp.Models { [Required(ErrorMessage = "Le pseudo est obligatoire.")] - [MinLength(4, ErrorMessage = "Le pseudo est trop long")] + [MinLength(4, ErrorMessage = "Le pseudo est trop court")] + [MaxLength(50, ErrorMessage = "Le pseudo est trop long")] public string? UserName { get; set; } - [Required(ErrorMessage = "L'email est obligatoire.")] - [RegularExpression(@"^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$", ErrorMessage = "Le format de l'email n'est pas correcte.")] - public string? Email { get; set; } - [Required(ErrorMessage = "Le mot de passe est obligatoire.")] - [StringLength(50, ErrorMessage = "Le mot de passe est trop long")] + [MinLength(4, ErrorMessage = "Le mot de passe est trop court")] public string? Password { get; set; } [Required(ErrorMessage = "Vous devez confirmer votre mot de passe")] diff --git a/src/CraftSharp/Pages/Connexion.razor b/src/CraftSharp/Pages/Connexion.razor index 8860eb4..3ed8ca3 100644 --- a/src/CraftSharp/Pages/Connexion.razor +++ b/src/CraftSharp/Pages/Connexion.razor @@ -18,11 +18,11 @@
- +
- +
Creer un compte
diff --git a/src/CraftSharp/Pages/Index.razor b/src/CraftSharp/Pages/Index.razor index 9e483fe..b469fd4 100644 --- a/src/CraftSharp/Pages/Index.razor +++ b/src/CraftSharp/Pages/Index.razor @@ -12,6 +12,27 @@
-Welcome to your new app. + + +

Hello @context.User.Identity.Name !!

+ +

Welcome to Blazor Learner.

+ +
    + @foreach (var claim in context.User.Claims) + { +
  • @claim.Type: @claim.Value
  • + } +
+ +
+ +

Loading ...

+
+ +

Echec de la connexion!

+

Vous n'etes pas connecté

+
+
diff --git a/src/CraftSharp/Pages/Inscription.razor b/src/CraftSharp/Pages/Inscription.razor index 89f3a6c..4a7394d 100644 --- a/src/CraftSharp/Pages/Inscription.razor +++ b/src/CraftSharp/Pages/Inscription.razor @@ -5,11 +5,12 @@

Inscription

-
diff --git a/src/CraftSharp/Shared/HeaderLayout.razor.cs b/src/CraftSharp/Shared/HeaderLayout.razor.cs index 6141ebf..a6e8983 100644 --- a/src/CraftSharp/Shared/HeaderLayout.razor.cs +++ b/src/CraftSharp/Shared/HeaderLayout.razor.cs @@ -1,4 +1,6 @@ -using Microsoft.AspNetCore.Components; +using CraftSharp.Services; +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Authorization; using Microsoft.Extensions.Localization; @@ -9,6 +11,15 @@ namespace CraftSharp.Shared [Inject] public IStringLocalizer Localizer { get; set; } + [Inject] + public CustomStateProvider AuthStateProvider { get; set; } + + [Inject] + public NavigationManager NavigationManager { get; set; } + + [CascadingParameter] + private Task AuthenticationState { get; set; } + void goInscription() { navigationManager.NavigateTo("inscription"); @@ -18,5 +29,19 @@ namespace CraftSharp.Shared { navigationManager.NavigateTo("connexion"); } + + protected override async Task OnParametersSetAsync() + { + if (!(await AuthenticationState).User.Identity.IsAuthenticated) + { + NavigationManager.NavigateTo("/inscription"); + } + } + + private async Task LogoutClick() + { + await AuthStateProvider.Logout(); + NavigationManager.NavigateTo("/inscription"); + } } } diff --git a/src/CraftSharp/Shared/InscriptionLayout.razor b/src/CraftSharp/Shared/InscriptionLayout.razor index 978904d..eb6b7a0 100644 --- a/src/CraftSharp/Shared/InscriptionLayout.razor +++ b/src/CraftSharp/Shared/InscriptionLayout.razor @@ -2,7 +2,6 @@ @inject NavigationManager navigationManager
-
diff --git a/src/CraftSharp/Shared/InscriptionLayout.razor.cs b/src/CraftSharp/Shared/InscriptionLayout.razor.cs index cb4739f..e89d3b4 100644 --- a/src/CraftSharp/Shared/InscriptionLayout.razor.cs +++ b/src/CraftSharp/Shared/InscriptionLayout.razor.cs @@ -6,9 +6,6 @@ namespace CraftSharp.Shared { public partial class InscriptionLayout { - void getBack() - { - navigationManager.NavigateTo(""); - } + } } diff --git a/src/CraftSharp/Shared/InscriptionLayout.razor.css b/src/CraftSharp/Shared/InscriptionLayout.razor.css index fd35265..bb16e76 100644 --- a/src/CraftSharp/Shared/InscriptionLayout.razor.css +++ b/src/CraftSharp/Shared/InscriptionLayout.razor.css @@ -29,10 +29,10 @@ footer { justify-content: space-between; } - footer p { - color: white; - font-family: Minecraft; - } +footer p { + color: white; + font-family: Minecraft; +} .p2 { float: right; @@ -50,3 +50,8 @@ button { padding-top: 6px; font-family: Minecraft; } + +h1 { + color: white; + font-family: Minecraft; +} \ No newline at end of file diff --git a/src/CraftSharp/_Imports.razor b/src/CraftSharp/_Imports.razor index b191629..db445a0 100644 --- a/src/CraftSharp/_Imports.razor +++ b/src/CraftSharp/_Imports.razor @@ -10,4 +10,5 @@ @using CraftSharp.Shared @using Blazorise.DataGrid @using Blazored.Modal -@using Blazored.Modal.Services \ No newline at end of file +@using Blazored.Modal.Services +@using Microsoft.AspNetCore.Components.Authorization \ No newline at end of file diff --git a/src/CraftSharp/wwwroot/font/Minecraft.ttf b/src/CraftSharp/wwwroot/fonts/Minecraft.ttf similarity index 100% rename from src/CraftSharp/wwwroot/font/Minecraft.ttf rename to src/CraftSharp/wwwroot/fonts/Minecraft.ttf diff --git a/src/CraftSharp/wwwroot/fonts/Minecraft.zip b/src/CraftSharp/wwwroot/fonts/Minecraft.zip new file mode 100644 index 0000000000000000000000000000000000000000..60082877d05fa74068d5f24c10308e5bd90b2d4d GIT binary patch literal 4717 zcmZ{o^;Z;tm&J$f76g$7=@RKiq+#ezVd!D#E9Zq?tpO59;ZqX6CHa?9&t1r!AdVAfsNq%_J)_^!|KnS zf@qNI&M*4KxK#HlT>uKu>pXNM`R59Iq;c)_qSHgJlkE(dQ2>|q#je68=LlAqQK8pb6^%3_Yv z;u(J#897f$MMIrq=;2a%by% z@ZfE>_gYb>lXcT-X24O)%gUbMdpg%YvRHKPdsb0&ZrfUlbRI`;gE_97%B(r=2M#5? zlf(O!4HJkXxqLj&k(QxByNn*HeInlc?!*Q9CGBUz!oz)T2=}SW=}YOqK4-vd$aT); z`kC})2(}O*5B3RRCpMy||LpclK25$!K~sK>hn36VN?FUY$7z4SVAT!mK{I&bLGU)} ze4Si~>&VEEOTysB#y&hxCyJKp&ewN(V9qc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