Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Core/AdminConsole/Entities/OrganizationUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public class OrganizationUser : ITableObject<Guid>, IExternal, IOrganizationUser
public string? ResetPasswordKey { get; set; }
/// <inheritdoc cref="OrganizationUserStatusType"/>
public OrganizationUserStatusType Status { get; set; }
/// <inheritdoc cref="OrganizationUserStatusTypeNew"/>
Copy link
Copy Markdown
Member

@eliykat eliykat May 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could do with some more explicit documentation at this stage. e.g.

This is not fully in use yet and should not be used outside the restore/revoke flows.
It is only used to back up the Status before revoking a user, and restore
the user to the correct status later. It should be null if the user is not revoked.

(also non-blocking)

public OrganizationUserStatusTypeNew? StatusNew { get; set; }
/// <summary>
/// The User's role in the Organization.
/// </summary>
Expand Down
17 changes: 17 additions & 0 deletions src/Core/AdminConsole/Enums/OrganizationUserStatusTypeNew.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
ο»Ώusing Bit.Core.Entities;

namespace Bit.Core.Enums;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be in Bit.Core.AdminConsole.Enums. The only reason our current enum isn't is that moving it would trigger code owner review bingo.

This is non-blocking and can be addressed in a later PR.


/// <summary>
/// Represents the different stages of a member's lifecycle in an organization.
/// The <see cref="OrganizationUser"/> object is populated differently depending on their Status.
/// </summary>
/// <remarks>
/// This is effectively a v2 version of OrganizationUserStatusType that severs Revoked as a status type.
/// </remarks>
public enum OrganizationUserStatusTypeNew : short
{
Invited = 0,
Accepted = 1,
Confirmed = 2,
}
9 changes: 6 additions & 3 deletions src/Sql/dbo/Stored Procedures/OrganizationUser_Create.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
@Permissions NVARCHAR(MAX),
@ResetPasswordKey VARCHAR(MAX),
@AccessSecretsManager BIT = 0,
@RevocationReason TINYINT = NULL
@RevocationReason TINYINT = NULL,
@StatusNew SMALLINT = NULL
AS
BEGIN
SET NOCOUNT ON
Expand All @@ -32,7 +33,8 @@ BEGIN
[Permissions],
[ResetPasswordKey],
[AccessSecretsManager],
[RevocationReason]
[RevocationReason],
[StatusNew]
)
VALUES
(
Expand All @@ -49,6 +51,7 @@ BEGIN
@Permissions,
@ResetPasswordKey,
@AccessSecretsManager,
@RevocationReason
@RevocationReason,
@StatusNew
)
END
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ BEGIN
[Permissions],
[ResetPasswordKey],
[AccessSecretsManager],
[RevocationReason]
[RevocationReason],
[StatusNew]
)
SELECT
OUI.[Id],
Expand All @@ -35,7 +36,8 @@ BEGIN
OUI.[Permissions],
OUI.[ResetPasswordKey],
OUI.[AccessSecretsManager],
OUI.[RevocationReason]
OUI.[RevocationReason],
OUI.[StatusNew]
FROM
OPENJSON(@jsonData)
WITH (
Expand All @@ -52,6 +54,7 @@ BEGIN
[Permissions] NVARCHAR (MAX) '$.Permissions',
[ResetPasswordKey] VARCHAR (MAX) '$.ResetPasswordKey',
[AccessSecretsManager] BIT '$.AccessSecretsManager',
[RevocationReason] TINYINT '$.RevocationReason'
[RevocationReason] TINYINT '$.RevocationReason',
[StatusNew] SMALLINT '$.StatusNew'
) OUI
END
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ BEGIN
[Permissions],
[ResetPasswordKey],
[AccessSecretsManager],
[RevocationReason]
[RevocationReason],
[StatusNew]
)
SELECT
OUI.[Id],
Expand All @@ -38,7 +39,8 @@ BEGIN
OUI.[Permissions],
OUI.[ResetPasswordKey],
OUI.[AccessSecretsManager],
OUI.[RevocationReason]
OUI.[RevocationReason],
OUI.[StatusNew]
FROM
OPENJSON(@organizationUserData)
WITH (
Expand All @@ -55,7 +57,8 @@ BEGIN
[Permissions] NVARCHAR (MAX) '$.Permissions',
[ResetPasswordKey] VARCHAR (MAX) '$.ResetPasswordKey',
[AccessSecretsManager] BIT '$.AccessSecretsManager',
[RevocationReason] TINYINT '$.RevocationReason'
[RevocationReason] TINYINT '$.RevocationReason',
[StatusNew] SMALLINT '$.StatusNew'
) OUI

INSERT INTO [dbo].[GroupUser]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ CREATE PROCEDURE [dbo].[OrganizationUser_CreateWithCollections]
@ResetPasswordKey VARCHAR(MAX),
@Collections AS [dbo].[CollectionAccessSelectionType] READONLY,
@AccessSecretsManager BIT = 0,
@RevocationReason TINYINT = NULL
@RevocationReason TINYINT = NULL,
@StatusNew SMALLINT = NULL
AS
BEGIN
SET NOCOUNT ON

EXEC [dbo].[OrganizationUser_Create] @Id, @OrganizationId, @UserId, @Email, @Key, @Status, @Type, @ExternalId, @CreationDate, @RevisionDate, @Permissions, @ResetPasswordKey, @AccessSecretsManager, @RevocationReason
EXEC [dbo].[OrganizationUser_Create] @Id, @OrganizationId, @UserId, @Email, @Key, @Status, @Type, @ExternalId, @CreationDate, @RevisionDate, @Permissions, @ResetPasswordKey, @AccessSecretsManager, @RevocationReason, @StatusNew

;WITH [AvailableCollectionsCTE] AS(
SELECT
Expand Down
6 changes: 4 additions & 2 deletions src/Sql/dbo/Stored Procedures/OrganizationUser_Update.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
@Permissions NVARCHAR(MAX),
@ResetPasswordKey VARCHAR(MAX),
@AccessSecretsManager BIT = 0,
@RevocationReason TINYINT = NULL
@RevocationReason TINYINT = NULL,
@StatusNew SMALLINT = NULL
AS
BEGIN
SET NOCOUNT ON
Expand All @@ -32,7 +33,8 @@ BEGIN
[Permissions] = @Permissions,
[ResetPasswordKey] = @ResetPasswordKey,
[AccessSecretsManager] = @AccessSecretsManager,
[RevocationReason] = @RevocationReason
[RevocationReason] = @RevocationReason,
[StatusNew] = @StatusNew
WHERE
[Id] = @Id

Expand Down
12 changes: 8 additions & 4 deletions src/Sql/dbo/Stored Procedures/OrganizationUser_UpdateMany.sql
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ BEGIN
[Permissions] NVARCHAR(MAX),
[ResetPasswordKey] VARCHAR(MAX),
[AccessSecretsManager] BIT,
[RevocationReason] TINYINT NULL
[RevocationReason] TINYINT NULL,
[StatusNew] SMALLINT NULL
)

INSERT INTO @OrganizationUserInput
Expand All @@ -39,7 +40,8 @@ BEGIN
[Permissions],
[ResetPasswordKey],
[AccessSecretsManager],
[RevocationReason]
[RevocationReason],
[StatusNew]
FROM OPENJSON(@jsonData)
WITH (
[Id] UNIQUEIDENTIFIER '$.Id',
Expand All @@ -55,7 +57,8 @@ BEGIN
[Permissions] NVARCHAR (MAX) '$.Permissions',
[ResetPasswordKey] VARCHAR (MAX) '$.ResetPasswordKey',
[AccessSecretsManager] BIT '$.AccessSecretsManager',
[RevocationReason] TINYINT '$.RevocationReason'
[RevocationReason] TINYINT '$.RevocationReason',
[StatusNew] SMALLINT '$.StatusNew'
)

-- Perform the update
Expand All @@ -74,7 +77,8 @@ BEGIN
[Permissions] = OUI.[Permissions],
[ResetPasswordKey] = OUI.[ResetPasswordKey],
[AccessSecretsManager] = OUI.[AccessSecretsManager],
[RevocationReason] = OUI.[RevocationReason]
[RevocationReason] = OUI.[RevocationReason],
[StatusNew] = OUI.[StatusNew]
FROM
[dbo].[OrganizationUser] OU
INNER JOIN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
@ResetPasswordKey VARCHAR(MAX),
@Collections AS [dbo].[CollectionAccessSelectionType] READONLY,
@AccessSecretsManager BIT = 0,
@RevocationReason TINYINT = NULL
@RevocationReason TINYINT = NULL,
@StatusNew SMALLINT = NULL
AS
BEGIN
SET NOCOUNT ON

EXEC [dbo].[OrganizationUser_Update] @Id, @OrganizationId, @UserId, @Email, @Key, @Status, @Type, @ExternalId, @CreationDate, @RevisionDate, @Permissions, @ResetPasswordKey, @AccessSecretsManager, @RevocationReason
EXEC [dbo].[OrganizationUser_Update] @Id, @OrganizationId, @UserId, @Email, @Key, @Status, @Type, @ExternalId, @CreationDate, @RevisionDate, @Permissions, @ResetPasswordKey, @AccessSecretsManager, @RevocationReason, @StatusNew

-- Bump RevisionDate on all affected collections
;WITH [AffectedCollectionsCTE] AS (
Expand Down
1 change: 1 addition & 0 deletions src/Sql/dbo/Tables/OrganizationUser.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
[Permissions] NVARCHAR (MAX) NULL,
[AccessSecretsManager] BIT NOT NULL CONSTRAINT [DF_OrganizationUser_SecretsManager] DEFAULT (0),
[RevocationReason] TINYINT NULL,
[StatusNew] SMALLINT NULL,
CONSTRAINT [PK_OrganizationUser] PRIMARY KEY CLUSTERED ([Id] ASC),
CONSTRAINT [FK_OrganizationUser_Organization] FOREIGN KEY ([OrganizationId]) REFERENCES [dbo].[Organization] ([Id]) ON DELETE CASCADE,
CONSTRAINT [FK_OrganizationUser_User] FOREIGN KEY ([UserId]) REFERENCES [dbo].[User] ([Id])
Expand Down
Loading
Loading