diff --git a/src/CraftSharp/App.razor b/src/CraftSharp/App.razor index ca31ce6..d4b64e7 100644 --- a/src/CraftSharp/App.razor +++ b/src/CraftSharp/App.razor @@ -12,11 +12,11 @@ @{ErrorHandler(5);}


- Oups, la page que à laquelle vous essayez d'accéder n'existe pas ! -

Retour à la page d'accueil dans 5s

+ @Localizer["Unknown Page"] +

@Localizer["Countdown"]



- + diff --git a/src/CraftSharp/App.razor.cs b/src/CraftSharp/App.razor.cs index 915b810..acc5f89 100644 --- a/src/CraftSharp/App.razor.cs +++ b/src/CraftSharp/App.razor.cs @@ -1,5 +1,6 @@ using CraftSharp.Shared; using Microsoft.AspNetCore.Components; +using Microsoft.Extensions.Localization; namespace CraftSharp { @@ -11,14 +12,18 @@ namespace CraftSharp [Inject] public ILogger Logger { get; set; } - public async Task ErrorHandler(int countdown) { + [Inject] + public IStringLocalizer Localizer { get; set; } + + public async Task ErrorHandler(int countdown) + { Logger.Log(LogLevel.Error, $"Navigating to unknown page : {NavigationManager.Uri}"); - while(countdown > 0) + while (countdown > 0) { await Task.Delay(1000); countdown--; - StateHasChanged(); } + countdown = 5; NavigationManager.NavigateTo("index"); } diff --git a/src/CraftSharp/Pages/Inscription.razor.cs b/src/CraftSharp/Pages/Inscription.razor.cs index 38f2417..cc747b7 100644 --- a/src/CraftSharp/Pages/Inscription.razor.cs +++ b/src/CraftSharp/Pages/Inscription.razor.cs @@ -36,14 +36,21 @@ namespace CraftSharp.Pages private async Task OnSubmit() { - - await AuthStateProvider.Register(registerRequest); - var stringified = JsonConvert.SerializeObject(new ConnexionModel() { - Password=registerRequest.Password, - UserName=registerRequest.UserName} - ); - var response = await httpClient.PostAsJsonAsync($"{NavigationManager.BaseUri}User/SetUser", stringified); - NavigationManager.NavigateTo("index"); + try + { + await AuthStateProvider.Register(registerRequest); + var stringified = JsonConvert.SerializeObject(new ConnexionModel() + { + Password = registerRequest.Password, + UserName = registerRequest.UserName + } + ); + var response = await httpClient.PostAsJsonAsync($"{NavigationManager.BaseUri}User/SetUser", stringified); + NavigationManager.NavigateTo("index"); + }catch (Exception ex) + { + error = ex.Message; + } } } diff --git a/src/CraftSharp/Resources/App.fr-FR.resx b/src/CraftSharp/Resources/App.fr-FR.resx new file mode 100644 index 0000000..e47d487 --- /dev/null +++ b/src/CraftSharp/Resources/App.fr-FR.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Retour à la page d'accueil dans 5s + + + Oups, la page que à laquelle vous essayez d'accéder n'existe pas ! + + \ No newline at end of file diff --git a/src/CraftSharp/Resources/App.resx b/src/CraftSharp/Resources/App.resx new file mode 100644 index 0000000..fcfd0f0 --- /dev/null +++ b/src/CraftSharp/Resources/App.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Redirection to home page in 5s + + + Oops, the page you're trying to access doesn't exists ! + + \ No newline at end of file diff --git a/src/CraftSharp/Resources/App.tr-TR.resx b/src/CraftSharp/Resources/App.tr-TR.resx new file mode 100644 index 0000000..f0c7784 --- /dev/null +++ b/src/CraftSharp/Resources/App.tr-TR.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 5 saniye içinde ana sayfaya dön + + + Hata, erişmeye çalıştığınız sayfa mevcut değil! + + \ No newline at end of file diff --git a/src/CraftSharp/Services/AuthService.cs b/src/CraftSharp/Services/AuthService.cs index 8249e6f..d384a60 100644 --- a/src/CraftSharp/Services/AuthService.cs +++ b/src/CraftSharp/Services/AuthService.cs @@ -65,7 +65,17 @@ namespace CraftSharp.Services public void Register(InscriptionModel registerRequest) { - CurrentUser.Add(new AppUser { UserName = registerRequest.UserName, Password = registerRequest.Password, Roles = new List { UserRoles.User } }); + var user = CurrentUser.FirstOrDefault(w => w.UserName == registerRequest.UserName); + + if (user == null) + { + CurrentUser.Add(new AppUser { UserName = registerRequest.UserName, Password = registerRequest.Password, Roles = new List { UserRoles.User } }); + } + else + { + throw new Exception("Username already taken !"); + + } } } }