mirror of
https://github.com/bitwarden/server.git
synced 2025-12-10 15:55:10 -06:00
[PM-26636] Set Key when Confirming (#6550)
* When confirming a uesr, we need to set the key. :face_palm: * Adding default value.
This commit is contained in:
parent
4fac635272
commit
4de10c830d
@ -681,7 +681,8 @@ public class OrganizationUserRepository : Repository<OrganizationUser, Guid>, IO
|
||||
{
|
||||
organizationUser.Id,
|
||||
organizationUser.UserId,
|
||||
RevisionDate = DateTime.UtcNow.Date
|
||||
RevisionDate = DateTime.UtcNow.Date,
|
||||
Key = organizationUser.Key
|
||||
});
|
||||
|
||||
return rowCount > 0;
|
||||
|
||||
@ -950,8 +950,9 @@ public class OrganizationUserRepository : Repository<Core.Entities.OrganizationU
|
||||
|
||||
var result = await dbContext.OrganizationUsers
|
||||
.Where(ou => ou.Id == organizationUser.Id && ou.Status == OrganizationUserStatusType.Accepted)
|
||||
.ExecuteUpdateAsync(x =>
|
||||
x.SetProperty(y => y.Status, OrganizationUserStatusType.Confirmed));
|
||||
.ExecuteUpdateAsync(x => x
|
||||
.SetProperty(y => y.Status, OrganizationUserStatusType.Confirmed)
|
||||
.SetProperty(y => y.Key, organizationUser.Key));
|
||||
|
||||
if (result <= 0)
|
||||
{
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
CREATE PROCEDURE [dbo].[OrganizationUser_ConfirmById]
|
||||
@Id UNIQUEIDENTIFIER,
|
||||
@UserId UNIQUEIDENTIFIER,
|
||||
@RevisionDate DATETIME2(7)
|
||||
@RevisionDate DATETIME2(7),
|
||||
@Key NVARCHAR(MAX) = NULL
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
@ -12,7 +13,8 @@ BEGIN
|
||||
[dbo].[OrganizationUser]
|
||||
SET
|
||||
[Status] = 2, -- Set to Confirmed
|
||||
[RevisionDate] = @RevisionDate
|
||||
[RevisionDate] = @RevisionDate,
|
||||
[Key] = @Key
|
||||
WHERE
|
||||
[Id] = @Id
|
||||
AND [Status] = 1 -- Only update if status is Accepted
|
||||
|
||||
@ -1484,6 +1484,8 @@ public class OrganizationUserRepositoryTests
|
||||
var organization = await organizationRepository.CreateTestOrganizationAsync();
|
||||
var user = await userRepository.CreateTestUserAsync();
|
||||
var orgUser = await organizationUserRepository.CreateAcceptedTestOrganizationUserAsync(organization, user);
|
||||
const string key = "test-key";
|
||||
orgUser.Key = key;
|
||||
|
||||
// Act
|
||||
var result = await organizationUserRepository.ConfirmOrganizationUserAsync(orgUser);
|
||||
@ -1493,6 +1495,7 @@ public class OrganizationUserRepositoryTests
|
||||
var updatedUser = await organizationUserRepository.GetByIdAsync(orgUser.Id);
|
||||
Assert.NotNull(updatedUser);
|
||||
Assert.Equal(OrganizationUserStatusType.Confirmed, updatedUser.Status);
|
||||
Assert.Equal(key, updatedUser.Key);
|
||||
|
||||
// Annul
|
||||
await organizationRepository.DeleteAsync(organization);
|
||||
|
||||
@ -0,0 +1,30 @@
|
||||
CREATE OR ALTER PROCEDURE [dbo].[OrganizationUser_ConfirmById]
|
||||
@Id UNIQUEIDENTIFIER,
|
||||
@UserId UNIQUEIDENTIFIER,
|
||||
@RevisionDate DATETIME2(7),
|
||||
@Key NVARCHAR(MAX) = NULL
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
DECLARE @RowCount INT;
|
||||
|
||||
UPDATE
|
||||
[dbo].[OrganizationUser]
|
||||
SET
|
||||
[Status] = 2, -- Set to Confirmed
|
||||
[RevisionDate] = @RevisionDate,
|
||||
[Key] = @Key
|
||||
WHERE
|
||||
[Id] = @Id
|
||||
AND [Status] = 1 -- Only update if status is Accepted
|
||||
|
||||
SET @RowCount = @@ROWCOUNT;
|
||||
|
||||
IF @RowCount > 0
|
||||
BEGIN
|
||||
EXEC [dbo].[User_BumpAccountRevisionDate] @UserId
|
||||
END
|
||||
|
||||
SELECT @RowCount;
|
||||
END
|
||||
Loading…
x
Reference in New Issue
Block a user