Profil: Logout after password change

This commit is contained in:
Andre Beging
2022-05-30 11:17:47 +02:00
parent 607fab1d04
commit e9f0bcc993
3 changed files with 19 additions and 4 deletions

View File

@@ -47,6 +47,11 @@ namespace FoodsharingSiegen.Server.BaseClasses
/// Gets or sets the value of the message (ab)
/// </summary>
[Inject] protected IMessageService? Message { get; set; }
/// <summary>
/// Gets or sets the value of the navigation manager (ab)
/// </summary>
[Inject] protected NavigationManager? NavigationManager { get; set; }
#endregion

View File

@@ -33,9 +33,17 @@
</Validations>
</Fields>
<hr />
<h3>Sicherheit</h3>
<Button Color="Color.Primary" Class="mb-2" Clicked="() => PasswordModal?.Show(User)!">Passwort ändern</Button>
<Button Color="Color.Danger" Class="mb-2" Clicked="RemoveAccount">Konto löschen</Button>
<p class="mt-4 mb-1">
Die Änderung deines Passworts ist sofort aktiv. Im Anschluss wirst du ausgeloggt und kannst dich neu einloggen.
<Button Color="Color.Primary" Class="d-block" Clicked="() => PasswordModal?.Show(User)!"><i class="fa-solid fa-key"></i>&nbsp;Passwort ändern</Button>
</p>
<p class="mt-4 mb-1">
Dein Konto zu löschen ist endgültig und kann nicht rückgängig gemacht werden.
<Button Color="Color.Danger" Class="d-block" Clicked="RemoveAccount"><i class="fa-solid fa-trash"></i>&nbsp;Konto löschen</Button>
</p>
</div>
<SetPasswordModal @ref="PasswordModal" OnPasswortSet="OnPasswordSet"></SetPasswordModal>

View File

@@ -92,8 +92,10 @@ namespace FoodsharingSiegen.Server.Pages
private async Task OnPasswordSet(User arg)
{
var setPasswordR = await UserService?.SetPassword(arg)!;
if(setPasswordR.Success)
await Notification?.Success("Dein neues Passwort wurde gespeichert")!;
if (setPasswordR.Success)
NavigationManager?.NavigateTo("/logout");
else
await Notification?.Success(setPasswordR.ErrorMessage)!;
}
#endregion