1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-29 23:26:12 -05:00

Update account revision date handling

This commit is contained in:
Thomas Rittson 2025-05-15 13:30:27 +10:00
parent 5dc559205d
commit 18181cd37b
No known key found for this signature in database
GPG Key ID: CDDDA03861C35E27
2 changed files with 12 additions and 3 deletions

View File

@ -36,6 +36,11 @@ public class User : ITableObject<Guid>, IStorableSubscriber, IRevisable, ITwoFac
public string? TwoFactorRecoveryCode { get; set; }
public string? EquivalentDomains { get; set; }
public string? ExcludedGlobalEquivalentDomains { get; set; }
/// <summary>
/// The Account Revision Date is used to check if new sync needs to occur. It should be updated
/// whenever a change is made that affects a client's sync data; for example, updating their vault or
/// organization membership.
/// </summary>
public DateTime AccountRevisionDate { get; set; } = DateTime.UtcNow;
public string? Key { get; set; }
public string? PublicKey { get; set; }

View File

@ -1,4 +1,5 @@
using AutoMapper;
using System.Diagnostics;
using AutoMapper;
using Bit.Core.AdminConsole.Enums;
using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.InviteUsers.Models;
using Bit.Core.Enums;
@ -445,12 +446,15 @@ public class OrganizationUserRepository : Repository<Core.Entities.OrganizationU
{
await base.ReplaceAsync(organizationUser);
// If the OrganizationUser is not linked to a User yet, we can't update the account revision date.
if (!organizationUser.UserId.HasValue)
// Only bump account revision dates for confirmed OrgUsers,
// as this is the only status that receives sync data from the organization
if (organizationUser.Status is not OrganizationUserStatusType.Confirmed)
{
return;
}
Debug.Assert(organizationUser.UserId is not null, "OrganizationUser is confirmed but does not have a UserId.");
using var scope = ServiceScopeFactory.CreateScope();
var dbContext = GetDatabaseContext(scope);
await dbContext.UserBumpAccountRevisionDateAsync(organizationUser.UserId.Value);