Add initial password setup functionality: implement email sending for new account password setup and update user interface to include password setup button

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
troogs
2026-04-26 11:00:43 +02:00
parent 870930914e
commit b0866754e0
3 changed files with 47 additions and 3 deletions

View File

@@ -56,9 +56,11 @@
</CardBody>
<CardFooter Class="d-flex justify-content-between">
<div>
<Button Color="Color.Primary" Size="Size.Small" Class="me-2" Clicked="() => EditUser(user)"><Icon Name="IconName.Edit" /></Button>
<Button Color="Color.Info" Size="Size.Small" Clicked="() => SetPassword(user)"><i class="fa-solid fa-key"></i></Button>
</div>
<Button Color="Color.Primary" Size="Size.Small" Clicked="() => EditUser(user)"><Icon Name="IconName.Edit" /></Button>
<Button Color="Color.Info" Size="Size.Small" Clicked="() => SetPassword(user)"><i class="fa-solid fa-key"></i></Button>
<Button Color="Color.Secondary" Size="Size.Small" Clicked="() => SendPasswordSetupMail(user)"><Icon Name="IconName.Mail" /></Button>
<Button Color="Color.Danger" Size="Size.Small" Clicked="() => RemoveUserAsync(user)"><Icon Name="IconName.Delete" /></Button>
</CardFooter>
</Card>
@@ -77,7 +79,7 @@
grid-template-columns: repeat(2, 1fr);
}
}
@@media (min-width: 1070px) {
@@media (min-width: 1250px) {
.user-grid {
grid-template-columns: repeat(3, 1fr);
}

View File

@@ -22,6 +22,12 @@ namespace FoodsharingSiegen.Server.Pages
[Inject]
public UserService UserService { get; set; } = null!;
[Inject]
public new FoodsharingSiegen.Server.Auth.AuthService AuthService { get; set; } = null!;
[Inject]
public new NavigationManager NavigationManager { get; set; } = null!;
#endregion
#region Private Properties
@@ -115,6 +121,14 @@ namespace FoodsharingSiegen.Server.Pages
PasswordModal?.Show(user);
}
private async Task SendPasswordSetupMail(User user)
{
await ConfirmDialog.ShowAsync(ModalService, "Bestätigen", $"Soll eine E-Mail zum Festlegen des Passworts an {user.Mail} gesendet werden?", async () =>
{
await AuthService.InitiateInitialPasswordSetup(user.Mail, NavigationManager.BaseUri);
});
}
private async Task SaveUser()
{
if (EditModel == null) return;