mirror of
https://github.com/bitwarden/server.git
synced 2024-11-22 12:15:36 +01:00
Fix empty grantee or grantor names in emergency access emails (#1162)
* Fix empty grantee or grantor names in emails * Add migrator dbscript for changes to ReadToNotify
This commit is contained in:
parent
b21c9042ca
commit
3850f0e400
@ -10,5 +10,6 @@ namespace Bit.Core.Models.Data
|
||||
{
|
||||
public string GrantorEmail { get; set; }
|
||||
public string GranteeName { get; set; }
|
||||
public string GranteeEmail { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -313,8 +313,10 @@ namespace Bit.Core.Services
|
||||
var ea = notify.ToEmergencyAccess();
|
||||
ea.LastNotificationDate = DateTime.UtcNow;
|
||||
await _emergencyAccessRepository.ReplaceAsync(ea);
|
||||
|
||||
await _mailService.SendEmergencyAccessRecoveryReminder(ea, notify.GranteeName, notify.GrantorEmail);
|
||||
|
||||
var granteeNameOrEmail = string.IsNullOrWhiteSpace(notify.GranteeName) ? notify.GranteeEmail : notify.GranteeName;
|
||||
|
||||
await _mailService.SendEmergencyAccessRecoveryReminder(ea, granteeNameOrEmail, notify.GrantorEmail);
|
||||
}
|
||||
}
|
||||
|
||||
@ -327,9 +329,12 @@ namespace Bit.Core.Services
|
||||
var ea = details.ToEmergencyAccess();
|
||||
ea.Status = EmergencyAccessStatusType.RecoveryApproved;
|
||||
await _emergencyAccessRepository.ReplaceAsync(ea);
|
||||
|
||||
await _mailService.SendEmergencyAccessRecoveryApproved(ea, details.GrantorName, details.GranteeEmail);
|
||||
await _mailService.SendEmergencyAccessRecoveryTimedOut(ea, details.GranteeName, details.GrantorEmail);
|
||||
|
||||
var grantorNameOrEmail = string.IsNullOrWhiteSpace(details.GrantorName) ? details.GrantorEmail : details.GrantorName;
|
||||
var granteeNameOrEmail = string.IsNullOrWhiteSpace(details.GranteeName) ? details.GranteeEmail : details.GranteeName;
|
||||
|
||||
await _mailService.SendEmergencyAccessRecoveryApproved(ea, grantorNameOrEmail, details.GranteeEmail);
|
||||
await _mailService.SendEmergencyAccessRecoveryTimedOut(ea, granteeNameOrEmail, details.GrantorEmail);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ BEGIN
|
||||
SELECT
|
||||
EA.*,
|
||||
Grantee.Name as GranteeName,
|
||||
Grantee.Email as GranteeEmail,
|
||||
Grantor.Email as GrantorEmail
|
||||
FROM
|
||||
[dbo].[EmergencyAccess] EA
|
||||
|
@ -0,0 +1,30 @@
|
||||
IF OBJECT_ID('[dbo].[EmergencyAccess_ReadToNotify]') IS NOT NULL
|
||||
BEGIN
|
||||
DROP PROCEDURE [dbo].[EmergencyAccess_ReadToNotify]
|
||||
END
|
||||
GO
|
||||
|
||||
CREATE PROCEDURE [dbo].[EmergencyAccess_ReadToNotify]
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
SELECT
|
||||
EA.*,
|
||||
Grantee.Name as GranteeName,
|
||||
Grantee.Email as GranteeEmail,
|
||||
Grantor.Email as GrantorEmail
|
||||
FROM
|
||||
[dbo].[EmergencyAccess] EA
|
||||
LEFT JOIN
|
||||
[dbo].[User] Grantor ON Grantor.[Id] = EA.[GrantorId]
|
||||
LEFT JOIN
|
||||
[dbo].[User] Grantee On Grantee.[Id] = EA.[GranteeId]
|
||||
WHERE
|
||||
EA.[Status] = 3
|
||||
AND
|
||||
DATEADD(DAY, EA.[WaitTimeDays] - 1, EA.[RecoveryInitiatedDate]) <= GETUTCDATE()
|
||||
AND
|
||||
DATEADD(DAY, 1, EA.[LastNotificationDate]) <= GETUTCDATE()
|
||||
END
|
||||
GO
|
Loading…
Reference in New Issue
Block a user