Skip to content

Commit 625f34f

Browse files
authored
clarify email as required with register/login #95 (#97)
* use MapStaticAssets() instead UseStaticFiles() * clarify email as required with register/login #95 * order MapStaticAssets() after Use*
1 parent ed8e367 commit 625f34f

4 files changed

Lines changed: 18 additions & 18 deletions

File tree

.vscode/launch.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"type": "coreclr",
1616
"request": "launch",
1717
"preLaunchTask": "build",
18-
"program": "${workspaceFolder}/Todo.Web/Server/bin/Debug/net8.0/Todo.Web.Server.dll",
18+
"program": "${workspaceFolder}/Todo.Web/Server/bin/Debug/net9.0/Todo.Web.Server.dll",
1919
"args": [],
2020
"cwd": "${workspaceFolder}/Todo.Web/Server",
2121
"launchSettingsProfile": "https",
@@ -37,7 +37,7 @@
3737
"request": "launch",
3838
"preLaunchTask": "build",
3939
// If you have changed target frameworks, make sure to update the program path.
40-
"program": "${workspaceFolder}/TodoApi/bin/Debug/net8.0/TodoApi.dll",
40+
"program": "${workspaceFolder}/TodoApi/bin/Debug/net9.0/TodoApi.dll",
4141
"args": [],
4242
"cwd": "${workspaceFolder}/TodoApi",
4343
"stopAtEntry": false,

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

Todo.Web/Server/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@
4040
}
4141

4242
app.UseHttpsRedirection();
43-
app.UseStaticFiles();
4443
app.UseAntiforgery();
4544

45+
app.MapStaticAssets();
4646
app.MapRazorComponents<App>()
4747
.AddInteractiveWebAssemblyRenderMode();
4848

0 commit comments

Comments
 (0)