diff --git a/.vscode/launch.json b/.vscode/launch.json index dcdc84e6..c5fbd1e8 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -15,7 +15,7 @@ "type": "coreclr", "request": "launch", "preLaunchTask": "build", - "program": "${workspaceFolder}/Todo.Web/Server/bin/Debug/net8.0/Todo.Web.Server.dll", + "program": "${workspaceFolder}/Todo.Web/Server/bin/Debug/net9.0/Todo.Web.Server.dll", "args": [], "cwd": "${workspaceFolder}/Todo.Web/Server", "launchSettingsProfile": "https", @@ -37,7 +37,7 @@ "request": "launch", "preLaunchTask": "build", // If you have changed target frameworks, make sure to update the program path. - "program": "${workspaceFolder}/TodoApi/bin/Debug/net8.0/TodoApi.dll", + "program": "${workspaceFolder}/TodoApi/bin/Debug/net9.0/TodoApi.dll", "args": [], "cwd": "${workspaceFolder}/TodoApi", "stopAtEntry": false, diff --git a/Todo.Web/Client/Components/LogInForm.razor b/Todo.Web/Client/Components/LogInForm.razor index ecd72508..39afffd6 100644 --- a/Todo.Web/Client/Components/LogInForm.razor +++ b/Todo.Web/Client/Components/LogInForm.razor @@ -3,9 +3,9 @@
- - - + + +
@@ -34,8 +34,8 @@ string? alertMessage; [Required] - [StringLength(15)] - public string? Username { get; set; } + [StringLength(256)] + public string? Email { get; set; } [Required] [StringLength(32, MinimumLength = 6, ErrorMessage = "The password must be between 6 and 32 characters long.")] @@ -53,9 +53,9 @@ async Task Login() { alertMessage = null; - if (await Client.LoginAsync(Username, Password)) + if (await Client.LoginAsync(Email, Password)) { - await OnLoggedIn.InvokeAsync(Username); + await OnLoggedIn.InvokeAsync(Email); } else { @@ -66,9 +66,9 @@ async Task Create() { alertMessage = null; - if (await Client.CreateUserAsync(Username, Password)) + if (await Client.CreateUserAsync(Email, Password)) { - await OnLoggedIn.InvokeAsync(Username); + await OnLoggedIn.InvokeAsync(Email); } else { diff --git a/Todo.Web/Client/TodoClient.cs b/Todo.Web/Client/TodoClient.cs index 151dfb36..69e60a74 100644 --- a/Todo.Web/Client/TodoClient.cs +++ b/Todo.Web/Client/TodoClient.cs @@ -50,25 +50,25 @@ public async Task DeleteTodoAsync(int id) return (statusCode, todos); } - public async Task LoginAsync(string? username, string? password) + public async Task LoginAsync(string? email, string? password) { - if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password)) + if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password)) { return false; } - var response = await client.PostAsJsonAsync("auth/login", new UserInfo { Email = username, Password = password }); + var response = await client.PostAsJsonAsync("auth/login", new UserInfo { Email = email, Password = password }); return response.IsSuccessStatusCode; } - public async Task CreateUserAsync(string? username, string? password) + public async Task CreateUserAsync(string? email, string? password) { - if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password)) + if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password)) { return false; } - var response = await client.PostAsJsonAsync("auth/register", new UserInfo { Email = username, Password = password }); + var response = await client.PostAsJsonAsync("auth/register", new UserInfo { Email = email, Password = password }); return response.IsSuccessStatusCode; } diff --git a/Todo.Web/Server/Program.cs b/Todo.Web/Server/Program.cs index 2825e92a..c28a1bb6 100644 --- a/Todo.Web/Server/Program.cs +++ b/Todo.Web/Server/Program.cs @@ -40,9 +40,9 @@ } app.UseHttpsRedirection(); -app.UseStaticFiles(); app.UseAntiforgery(); +app.MapStaticAssets(); app.MapRazorComponents() .AddInteractiveWebAssemblyRenderMode();