mirror of
https://github.com/bitwarden/server.git
synced 2025-06-03 17:50:32 -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:
parent
fe6181f55f
commit
c7b0c30370
@ -1,5 +1,4 @@
|
|||||||
using System.Diagnostics;
|
using AutoMapper;
|
||||||
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;
|
||||||
@ -446,15 +445,12 @@ public class OrganizationUserRepository : Repository<Core.Entities.OrganizationU
|
|||||||
{
|
{
|
||||||
await base.ReplaceAsync(organizationUser);
|
await base.ReplaceAsync(organizationUser);
|
||||||
|
|
||||||
// Only bump account revision dates for confirmed OrgUsers,
|
// Only bump the account revision date if linked to a user account
|
||||||
// as this is the only status that receives sync data from the organization
|
if (!organizationUser.UserId.HasValue)
|
||||||
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);
|
||||||
|
@ -45,9 +45,6 @@ public class OrganizationUserReplaceTests
|
|||||||
/// Tests OrganizationUsers in the Confirmed status, which is a stand-in for all other
|
/// Tests OrganizationUsers in the Confirmed status, which is a stand-in for all other
|
||||||
/// non-Invited statuses (which are all linked to a UserId).
|
/// non-Invited statuses (which are all linked to a UserId).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="organizationRepository"></param>
|
|
||||||
/// <param name="organizationUserRepository"></param>
|
|
||||||
/// <param name="collectionRepository"></param>
|
|
||||||
[DatabaseTheory, DatabaseData]
|
[DatabaseTheory, DatabaseData]
|
||||||
public async Task ReplaceAsync_WithCollectionAccess_WhenUserIsConfirmed_Success(
|
public async Task ReplaceAsync_WithCollectionAccess_WhenUserIsConfirmed_Success(
|
||||||
IUserRepository userRepository,
|
IUserRepository userRepository,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user