insight/src/Web/Insight.Web/Pages/Account/ProfilePasswordDialog.razor.cs

30 lines
913 B
C#
Raw Normal View History

2023-09-21 18:58:32 +02:00
using Insight.Infrastructure.Entities;
using Insight.Web.Constants;
using Insight.Web.Middleware;
using Insight.Web.Models.Account;
using Microsoft.AspNetCore.Components;
using MudBlazor;
namespace Insight.Web.Pages.Account;
public partial class ProfilePasswordDialog
{
[CascadingParameter(Name = "User")] public InsightUser? User { get; set; }
[Inject] private NavigationManager NavigationManager { get; init; } = default!;
[Inject] private ISnackbar Snackbar { get; init; } = default!;
private void Submit(ChangePasswordModel model)
{
if (model.NewPassword != model.ConfirmNewPassword)
{
Notification.Error(Snackbar, "Passwords not matching");
return;
}
var key = Guid.NewGuid();
IdentityMiddleware.Passwords[key] = model;
NavigationManager.NavigateTo(Navigation.Account.ChangePasswordHref(key), true);
}
}