Added delete user button

This commit is contained in:
Sarah Faey 2022-12-01 21:42:43 +01:00
parent ce405a3e36
commit 26dd595057
2 changed files with 38 additions and 1 deletions

View file

@ -7,6 +7,7 @@
@inject UserService UserService
@inject NavigationManager NavigationManager
@inject AuthenticationStateProvider AuthenticationStateProvider
@inject IJSRuntime JsRuntime
<h3>Manage Account</h3>
@ -71,6 +72,12 @@
<br />
<button type="submit">Save</button>
<ValidationSummary />
<br/>
<br/>
<br/>
<br/>
<br/>
<a href="Account/Logout" class="loginText" @onclick="() => DeleteAccountClicked()">Delete Account</a>
</EditForm>
</Authorized>
</AuthorizeView>
@ -99,4 +106,17 @@
await UserService.EditUser(_user);
_saveMessage = "changes saved successfully";
}
async Task DeleteAccountClicked()
{
bool confirmed = await JsRuntime.InvokeAsync<bool>("confirm", "Are you sure you want to delete this Website Account?\nThis will sign you off in every raid in which you are signed up.");
if (confirmed)
{
await UserService.DeleteUser(_user);
}
else
{
NavigationManager.NavigateTo("accountedit");
}
}
}