Passwort setzen funktion

This commit is contained in:
Andre Beging
2022-05-20 07:47:38 +02:00
parent f80ba142bc
commit 21f4906277
9 changed files with 172 additions and 51 deletions

View File

@@ -0,0 +1,69 @@
@using FoodsharingSiegen.Contracts.Entity
@using FoodsharingSiegen.Shared.Helper
@using Microsoft.AspNetCore.Components
@code {
private Modal ModalReference { get; set; } = null!;
private User User { get; set; } = new();
private string Password { get; set; }
private string ConfirmPassword { get; set; }
[Parameter]
public EventCallback<User> OnPasswortSet { get; set; }
public async Task Show(User user)
{
User = user;
await ModalReference.Show();
}
private ValidationStatus IsValidPassword { get; set; }
private ValidationStatus IsValidConfirm { get; set; }
private bool SaveDisabled
{
get
{
if (IsValidPassword != ValidationStatus.Success) return true;
if (IsValidConfirm != ValidationStatus.Success) return true;
return Password != ConfirmPassword;
}
}
private async Task SaveClick(object arg)
{
User.Password = Password;
await OnPasswortSet.InvokeAsync(User);
await ModalReference.Hide();
}
}
<Modal @ref="@ModalReference">
<ModalContent Centered Size="ModalSize.Small">
<ModalHeader>
<ModalTitle>Passwort von @User.Name setzen</ModalTitle>
<CloseButton/>
</ModalHeader>
<ModalBody>
<Field>
<FieldLabel>Passwort</FieldLabel>
<Validation Validator="ValidationHelper.ValidatePassword" @bind-Status="@IsValidPassword">
<TextEdit @bind-Text="Password" Role="TextRole.Password" Placeholder="Passwort"></TextEdit>
</Validation>
</Field>
<Field>
<FieldLabel>Passwort wiederholen</FieldLabel>
<Validation Validator="ValidationHelper.ValidatePassword" @bind-Status="@IsValidConfirm">
<TextEdit @bind-Text="ConfirmPassword" Role="TextRole.Password" Placeholder="Passwort"></TextEdit>
</Validation>
</Field>
</ModalBody>
<ModalFooter>
<Button Color="Color.Secondary" Clicked="ModalReference.Hide">Abbrechen</Button>
<Button Color="Color.Primary" Clicked="SaveClick" Disabled="@SaveDisabled">Speichern</Button>
</ModalFooter>
</ModalContent>
</Modal>