Skip to content

Commit 29fb647

Browse files
committed
update demo app
1 parent 288af6b commit 29fb647

11 files changed

Lines changed: 447 additions & 16 deletions

File tree

demo/StaticSample/StaticSample.Client/Layout/MainLayout.razor

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,4 @@
2727

2828
@code {
2929
bool _drawerOpen = true;
30-
31-
void DrawerToggle()
32-
{
33-
_drawerOpen = !_drawerOpen;
34-
}
3530
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"dotnet-ef": {
6+
"version": "9.0.0",
7+
"commands": [
8+
"dotnet-ef"
9+
],
10+
"rollForward": false
11+
}
12+
}
13+
}

demo/StaticSample/StaticSample/Components/Account/Pages/Manage/ChangePassword.razor

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
<DataAnnotationsValidator />
2121

2222
<MudStaticTextField @bind-Value="Input.OldPassword" Label="Old password" Placeholder="Please enter your old password." Margin="Margin.Dense" Variant="Variant.Outlined"
23-
autocomplete="current-password" InputType="InputType.Password" For="() => Input.OldPassword" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Outlined.LockOpen" />
23+
autocomplete="current-password" InputType="InputType.Password" For="() => Input.OldPassword" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Outlined.LockOpen" />
2424

2525
<MudStaticTextField @bind-Value="Input.NewPassword" Label="New password" Placeholder="Please enter your new password." Margin="Margin.Dense" Variant="Variant.Outlined"
26-
Class="py-4" autocomplete="new-password" InputType="InputType.Password" For="() => Input.NewPassword" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Outlined.Lock" />
26+
Class="py-4" autocomplete="new-password" InputType="InputType.Password" For="() => Input.NewPassword" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Outlined.Lock" />
2727

2828
<MudStaticTextField @bind-Value="Input.ConfirmPassword" Label="Confirm password" Placeholder="Please confirm your new password." Margin="Margin.Dense" Variant="Variant.Outlined"
29-
autocomplete="new-password" InputType="InputType.Password" For="() => Input.ConfirmPassword" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Outlined.LockReset" />
30-
29+
autocomplete="new-password" InputType="InputType.Password" For="() => Input.ConfirmPassword" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Outlined.LockReset" />
30+
3131
<MudStaticButton Class="mt-4" Color="Color.Primary" Variant="Variant.Filled" FullWidth="true">Update Password</MudStaticButton>
3232
</EditForm>
3333

@@ -54,6 +54,12 @@
5454

5555
private async Task OnValidSubmitAsync()
5656
{
57+
if (user is { Email: ApplicationUser.DefaultEmail }) {
58+
59+
RedirectManager.RedirectToCurrentPageWithStatus("Password cannot be modified for the default account!", HttpContext);
60+
return;
61+
}
62+
5763
var changePasswordResult = await UserManager.ChangePasswordAsync(user, Input.OldPassword, Input.NewPassword);
5864
if (!changePasswordResult.Succeeded)
5965
{

demo/StaticSample/StaticSample/Components/Account/Pages/Manage/DeletePersonalData.razor

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@
5151

5252
private async Task OnValidSubmitAsync()
5353
{
54+
if (user is { Email: ApplicationUser.DefaultEmail })
55+
{
56+
RedirectManager.RedirectToCurrentPageWithStatus("Data cannot be deleted for the default account!", HttpContext);
57+
return;
58+
}
59+
5460
if (requirePassword && !await UserManager.CheckPasswordAsync(user, Input.Password))
5561
{
5662
message = "Error: Incorrect password.";
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
using Microsoft.AspNetCore.Identity;
22

3-
namespace StaticSample.Data
3+
namespace StaticSample.Data;
4+
5+
// Add profile data for application users by adding properties to the ApplicationUser class
6+
public class ApplicationUser : IdentityUser
47
{
5-
// Add profile data for application users by adding properties to the ApplicationUser class
6-
public class ApplicationUser : IdentityUser
7-
{
8-
}
8+
public const string DefaultEmail = "[email protected]";
99

10+
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
1011
}

demo/StaticSample/StaticSample/Data/Migrations/20241224123022_AddUserCreatedAtField.Designer.cs

Lines changed: 282 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)