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:
parent
5dc559205d
commit
18181cd37b
@ -36,6 +36,11 @@ public class User : ITableObject<Guid>, IStorableSubscriber, IRevisable, ITwoFac
|
|||||||
public string? TwoFactorRecoveryCode { get; set; }
|
public string? TwoFactorRecoveryCode { get; set; }
|
||||||
public string? EquivalentDomains { get; set; }
|
public string? EquivalentDomains { get; set; }
|
||||||
public string? ExcludedGlobalEquivalentDomains { 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 DateTime AccountRevisionDate { get; set; } = DateTime.UtcNow;
|
||||||
public string? Key { get; set; }
|
public string? Key { get; set; }
|
||||||
public string? PublicKey { get; set; }
|
public string? PublicKey { get; set; }
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using AutoMapper;
|
using System.Diagnostics;
|
||||||
|
using AutoMapper;
|
||||||
using Bit.Core.AdminConsole.Enums;
|
using Bit.Core.AdminConsole.Enums;
|
||||||
using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.InviteUsers.Models;
|
using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.InviteUsers.Models;
|
||||||
using Bit.Core.Enums;
|
using Bit.Core.Enums;
|
||||||
@ -445,12 +446,15 @@ public class OrganizationUserRepository : Repository<Core.Entities.OrganizationU
|
|||||||
{
|
{
|
||||||
await base.ReplaceAsync(organizationUser);
|
await base.ReplaceAsync(organizationUser);
|
||||||
|
|
||||||
// If the OrganizationUser is not linked to a User yet, we can't update the account revision date.
|
// Only bump account revision dates for confirmed OrgUsers,
|
||||||
if (!organizationUser.UserId.HasValue)
|
// as this is the only status that receives sync data from the organization
|
||||||
|
if (organizationUser.Status is not OrganizationUserStatusType.Confirmed)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Debug.Assert(organizationUser.UserId is not null, "OrganizationUser is confirmed but does not have a UserId.");
|
||||||
|
|
||||||
using var scope = ServiceScopeFactory.CreateScope();
|
using var scope = ServiceScopeFactory.CreateScope();
|
||||||
var dbContext = GetDatabaseContext(scope);
|
var dbContext = GetDatabaseContext(scope);
|
||||||
await dbContext.UserBumpAccountRevisionDateAsync(organizationUser.UserId.Value);
|
await dbContext.UserBumpAccountRevisionDateAsync(organizationUser.UserId.Value);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user