1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-02 01:00:33 -05:00

Bump account revision date in OrgUserRepository (#5884)

Match equivalent MSSQL logic. Also ensures that the revision date
is bumped when the user is revoked.
This commit is contained in:
Thomas Rittson 2025-05-29 07:30:23 +10:00 committed by GitHub
parent fe6181f55f
commit c7b0c30370
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 10 deletions

View File

@ -1,5 +1,4 @@
using System.Diagnostics;
using AutoMapper;
using AutoMapper;
using Bit.Core.AdminConsole.Enums;
using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.InviteUsers.Models;
using Bit.Core.Enums;
@ -446,15 +445,12 @@ public class OrganizationUserRepository : Repository<Core.Entities.OrganizationU
{
await base.ReplaceAsync(organizationUser);
// 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)
// Only bump the account revision date if linked to a user account
if (!organizationUser.UserId.HasValue)
{
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);

View File

@ -45,9 +45,6 @@ public class OrganizationUserReplaceTests
/// Tests OrganizationUsers in the Confirmed status, which is a stand-in for all other
/// non-Invited statuses (which are all linked to a UserId).
/// </summary>
/// <param name="organizationRepository"></param>
/// <param name="organizationUserRepository"></param>
/// <param name="collectionRepository"></param>
[DatabaseTheory, DatabaseData]
public async Task ReplaceAsync_WithCollectionAccess_WhenUserIsConfirmed_Success(
IUserRepository userRepository,