diff --git a/src/CraftSharp/Pages/Connexion.razor b/src/CraftSharp/Pages/Connexion.razor
index 43d4812..d7ed316 100644
--- a/src/CraftSharp/Pages/Connexion.razor
+++ b/src/CraftSharp/Pages/Connexion.razor
@@ -24,7 +24,7 @@
- Creer un compte
+ Creer un compte
diff --git a/src/CraftSharp/Pages/Connexion.razor.cs b/src/CraftSharp/Pages/Connexion.razor.cs
index 428c642..0202cf6 100644
--- a/src/CraftSharp/Pages/Connexion.razor.cs
+++ b/src/CraftSharp/Pages/Connexion.razor.cs
@@ -24,6 +24,9 @@ namespace CraftSharp.Pages
[Inject]
public HttpClient httpClient { get; set; }
+ [Inject]
+ public ILogger Logger { get; set; }
+
private string error { get; set; }
private ConnexionModel loginRequest { get; set; } = new ConnexionModel();
@@ -41,6 +44,7 @@ namespace CraftSharp.Pages
try
{
await AuthStateProvider.Login(loginRequest);
+ Logger.Log(LogLevel.Information, $"Login : {loginRequest.UserName}");
var stringified = JsonConvert.SerializeObject(loginRequest);
var response = await httpClient.PostAsJsonAsync($"{NavigationManager.BaseUri}User/SetUser", stringified);
NavigationManager.NavigateTo("index");
@@ -48,6 +52,7 @@ namespace CraftSharp.Pages
}
catch (Exception ex)
{
+ Logger.Log(LogLevel.Error, $"Login Failure : {ex}");
error = ex.Message;
}
}
diff --git a/src/CraftSharp/Pages/Inscription.razor b/src/CraftSharp/Pages/Inscription.razor
index 83af701..76ca222 100644
--- a/src/CraftSharp/Pages/Inscription.razor
+++ b/src/CraftSharp/Pages/Inscription.razor
@@ -28,7 +28,7 @@
- Vous avez un compte ? Connectez vous
+ Vous avez un compte ? Connectez vous
diff --git a/src/CraftSharp/Pages/Inscription.razor.cs b/src/CraftSharp/Pages/Inscription.razor.cs
index a3c523f..627ff82 100644
--- a/src/CraftSharp/Pages/Inscription.razor.cs
+++ b/src/CraftSharp/Pages/Inscription.razor.cs
@@ -21,6 +21,9 @@ namespace CraftSharp.Pages
[Inject]
public HttpClient httpClient { get; set; }
+ [Inject]
+ public ILogger Logger { get; set; }
+
private string error { get; set; }
private InscriptionModel registerRequest { get; set; } = new InscriptionModel();
@@ -28,6 +31,7 @@ namespace CraftSharp.Pages
{
if (AuthStateProvider.GetCurrentUser() != null && AuthStateProvider.GetCurrentUser().IsAuthenticated)
{
+ Logger.Log(LogLevel.Information, $"Automatic login : {AuthStateProvider.GetCurrentUser().UserName}");
NavigationManager.NavigateTo("index");
}
}
@@ -36,6 +40,7 @@ namespace CraftSharp.Pages
{
await AuthStateProvider.Register(registerRequest);
+ Logger.Log(LogLevel.Information, $"Register : {registerRequest.UserName}");
var stringified = JsonConvert.SerializeObject(new ConnexionModel() {
Password=registerRequest.Password,
UserName=registerRequest.UserName}
diff --git a/src/CraftSharp/Pages/_Host.cshtml b/src/CraftSharp/Pages/_Host.cshtml
index 3451d14..6683441 100644
--- a/src/CraftSharp/Pages/_Host.cshtml
+++ b/src/CraftSharp/Pages/_Host.cshtml
@@ -10,7 +10,6 @@
@{
Layout = "_Layout";
- Console.WriteLine("==============START==============");
var response = await httpClient.GetAsync($"https://localhost:7139/User/GetUser");
string jsonUser = await response.Content.ReadAsStringAsync();
var user = new ConnexionModel();
diff --git a/src/CraftSharp/Services/AuthService.cs b/src/CraftSharp/Services/AuthService.cs
index 347854f..5652c56 100644
--- a/src/CraftSharp/Services/AuthService.cs
+++ b/src/CraftSharp/Services/AuthService.cs
@@ -41,13 +41,10 @@ namespace CraftSharp.Services
public void Login(ConnexionModel loginRequest)
{
- Console.WriteLine("LOGIN : " + loginRequest.UserName);
var user = CurrentUser.FirstOrDefault(w => w.UserName == loginRequest.UserName && w.Password == loginRequest.Password);
if (user == null)
{
- Console.WriteLine("LOGINFAILED");
-
throw new Exception("User name or password invalid !");
}
}
diff --git a/src/CraftSharp/Services/CustomStateProvider.cs b/src/CraftSharp/Services/CustomStateProvider.cs
index f1bbc58..15327f2 100644
--- a/src/CraftSharp/Services/CustomStateProvider.cs
+++ b/src/CraftSharp/Services/CustomStateProvider.cs
@@ -73,11 +73,8 @@ namespace CraftSharp.Services
if (_currentUser != null && _currentUser.IsAuthenticated)
{
- Console.WriteLine("GETUSER: " + _currentUser.UserName);
return _currentUser;
}
- Console.WriteLine("GETUSER: FAIL");
-
return new CurrentUser();
}
}
diff --git a/src/CraftSharp/Shared/HeaderLayout.razor.cs b/src/CraftSharp/Shared/HeaderLayout.razor.cs
index 280476b..a5d2227 100644
--- a/src/CraftSharp/Shared/HeaderLayout.razor.cs
+++ b/src/CraftSharp/Shared/HeaderLayout.razor.cs
@@ -1,4 +1,5 @@
using CraftSharp.Models;
+using CraftSharp.Pages;
using CraftSharp.Services;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
@@ -22,6 +23,9 @@ namespace CraftSharp.Shared
[Inject]
public HttpClient httpClient { get; set; }
+ [Inject]
+ public ILogger Logger { get; set; }
+
[CascadingParameter]
private Task AuthenticationState { get; set; }
@@ -36,16 +40,6 @@ namespace CraftSharp.Shared
isAdmin();
}
- void goInscription()
- {
- NavigationManager.NavigateTo("inscription");
- }
-
- void goConnexion()
- {
- NavigationManager.NavigateTo("connexion");
- }
-
async public void isAdmin()
{
var roles = AuthStateProvider.GetCurrentUser().Roles;
@@ -54,6 +48,7 @@ namespace CraftSharp.Shared
private async Task LogoutClick()
{
await AuthStateProvider.Logout();
+ Logger.Log(LogLevel.Information, $"Logout : {AuthStateProvider.GetCurrentUser().UserName}");
await httpClient.DeleteAsync($"{NavigationManager.BaseUri}User/DeleteUser");
NavigationManager.NavigateTo("/inscription");