From d910f165a779222a02d559a26f0dbfc0755c09f3 Mon Sep 17 00:00:00 2001 From: GeeSuth Date: Wed, 20 Nov 2024 00:34:37 +0300 Subject: [PATCH] clarify email as required with register/login #95 --- Todo.Web/Client/Components/LogInForm.razor | 18 +++++++++--------- Todo.Web/Client/TodoClient.cs | 12 ++++++------ 2 files changed, 15 insertions(+), 15 deletions(-) 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; }