Skip to content

Commit d910f16

Browse files
committed
clarify email as required with register/login #95
1 parent 4871935 commit d910f16

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

Todo.Web/Client/Components/LogInForm.razor

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
<EditForm Model="@this" class="form-horizontal py-5" OnValidSubmit="@Login">
44
<DataAnnotationsValidator />
55
<div class="mb-3">
6-
<label for="username" class="form-label">User name</label>
7-
<InputText id="username" class="form-control" @bind-Value="Username" />
8-
<ValidationMessage For="@(() => Username)" />
6+
<label for="email" class="form-label">Email</label>
7+
<InputText id="email" class="form-control" @bind-Value="Email" />
8+
<ValidationMessage For="@(() => Email)" />
99
</div>
1010
<div class="mb-3">
1111
<label for="password" class="form-label">Password</label>
@@ -34,8 +34,8 @@
3434
string? alertMessage;
3535

3636
[Required]
37-
[StringLength(15)]
38-
public string? Username { get; set; }
37+
[StringLength(256)]
38+
public string? Email { get; set; }
3939

4040
[Required]
4141
[StringLength(32, MinimumLength = 6, ErrorMessage = "The password must be between 6 and 32 characters long.")]
@@ -53,9 +53,9 @@
5353
async Task Login()
5454
{
5555
alertMessage = null;
56-
if (await Client.LoginAsync(Username, Password))
56+
if (await Client.LoginAsync(Email, Password))
5757
{
58-
await OnLoggedIn.InvokeAsync(Username);
58+
await OnLoggedIn.InvokeAsync(Email);
5959
}
6060
else
6161
{
@@ -66,9 +66,9 @@
6666
async Task Create()
6767
{
6868
alertMessage = null;
69-
if (await Client.CreateUserAsync(Username, Password))
69+
if (await Client.CreateUserAsync(Email, Password))
7070
{
71-
await OnLoggedIn.InvokeAsync(Username);
71+
await OnLoggedIn.InvokeAsync(Email);
7272
}
7373
else
7474
{

Todo.Web/Client/TodoClient.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,25 +50,25 @@ public async Task<bool> DeleteTodoAsync(int id)
5050
return (statusCode, todos);
5151
}
5252

53-
public async Task<bool> LoginAsync(string? username, string? password)
53+
public async Task<bool> LoginAsync(string? email, string? password)
5454
{
55-
if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
55+
if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password))
5656
{
5757
return false;
5858
}
5959

60-
var response = await client.PostAsJsonAsync("auth/login", new UserInfo { Email = username, Password = password });
60+
var response = await client.PostAsJsonAsync("auth/login", new UserInfo { Email = email, Password = password });
6161
return response.IsSuccessStatusCode;
6262
}
6363

64-
public async Task<bool> CreateUserAsync(string? username, string? password)
64+
public async Task<bool> CreateUserAsync(string? email, string? password)
6565
{
66-
if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
66+
if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password))
6767
{
6868
return false;
6969
}
7070

71-
var response = await client.PostAsJsonAsync("auth/register", new UserInfo { Email = username, Password = password });
71+
var response = await client.PostAsJsonAsync("auth/register", new UserInfo { Email = email, Password = password });
7272
return response.IsSuccessStatusCode;
7373
}
7474

0 commit comments

Comments
 (0)