From 269b6c7c01f67446341445f1d3d3c161bab595a1 Mon Sep 17 00:00:00 2001 From: Jared McCannon Date: Mon, 23 Oct 2023 02:58:17 -0500 Subject: [PATCH] Fix for null reference on canceling admin invite. (#150) * Fixing null reference. * formatting fix --- src/AdminConsole/Pages/Organization/Admins.cshtml.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/AdminConsole/Pages/Organization/Admins.cshtml.cs b/src/AdminConsole/Pages/Organization/Admins.cshtml.cs index ea3fcb24c..c545de868 100644 --- a/src/AdminConsole/Pages/Organization/Admins.cshtml.cs +++ b/src/AdminConsole/Pages/Organization/Admins.cshtml.cs @@ -120,16 +120,19 @@ public async Task OnPostInvite(InviteForm form) public async Task OnPostCancel(string hashedCode) { + Invites = await _invitationService.GetInvitesAsync(User.GetOrgId().Value); + + var inviteToCancel = Invites.FirstOrDefault(x => x.HashedCode == hashedCode); + await _invitationService.CancelInviteAsync(hashedCode); var performedBy = await _dataService.GetUserAsync(); - var invitationCancelled = Invites.FirstOrDefault(x => x.HashedCode == hashedCode); - if (invitationCancelled is not null) + if (inviteToCancel is not null) { _eventLogger.LogCancelAdminInviteEvent( performedBy, - invitationCancelled.ToEmail, + inviteToCancel.ToEmail, _systemClock.UtcNow.UtcDateTime ); }