mirror of
https://github.com/bitwarden/server.git
synced 2024-11-30 13:33:24 +01:00
b412a01d2a
* SG-992 - Provider receives free org prompt when trying to auto scale org seats because plan type was missing and defaulting to free. PlanType has now been added to provider orgs returned as part of the profile sync. * SG-992 - Updated Stored proc name to match convention * EC-591 / SG-996 - (1) Update ProviderUserRepo.GetManyDetailsByProviderAsync to accept optional ProviderUserStatusType (2) Update OrganizationService.cs autoscaling user logic to check if an org is a provider org and send owner emails to the confirmed provider users instead of the managed org owners. Prevents scenario where newly created, managed orgs would not have an owner yet, and ownerEmails would be null and the email service would explode. * EC-591 / SG-996 - Remove comments * EC-591 / SG-996 - ES lint fix. * SG-996 - SQL files must have SQL extensions. * SG-996 / EC-591 - Update alter sql to be actually backwards compatible * SG-996 - Make Status actually optional and backwards compatible for ProviderUserUserDetails_ReadByProvider.sql * SG-992 - Update migrations to meet standards - (1) use CREATE OR ALTER and (2) Update view metadata after change if necessary * EC-591 / SG-996 - Update Stored Proc migration to use proper standards: (1) Remove unnecessary code and (2) Use CREATE OR ALTER instead of just ALTER * SG-992 / EC-591 / SG-996 - Refactor separate migrations into single migrations file per PR feedback * SG-992/SG-996 - Add SyncControllerTests.cs with basic test suite + specific test suite to ensure provider orgs have plan type mapped to output product type properly. * Fix lint issues by removing unnecessary using statements * SG-992 - Refresh of view metadata has to target the stored procs that reference the view -- not the view itself.
72 lines
1.7 KiB
Transact-SQL
72 lines
1.7 KiB
Transact-SQL
-- SG-992 changes: add planType to provider orgs
|
|
CREATE OR ALTER VIEW [dbo].[ProviderUserProviderOrganizationDetailsView]
|
|
AS
|
|
SELECT
|
|
PU.[UserId],
|
|
PO.[OrganizationId],
|
|
O.[Name],
|
|
O.[Enabled],
|
|
O.[UsePolicies],
|
|
O.[UseSso],
|
|
O.[UseKeyConnector],
|
|
O.[UseScim],
|
|
O.[UseGroups],
|
|
O.[UseDirectory],
|
|
O.[UseEvents],
|
|
O.[UseTotp],
|
|
O.[Use2fa],
|
|
O.[UseApi],
|
|
O.[UseResetPassword],
|
|
O.[SelfHost],
|
|
O.[UsersGetPremium],
|
|
O.[UseCustomPermissions],
|
|
O.[Seats],
|
|
O.[MaxCollections],
|
|
O.[MaxStorageGb],
|
|
O.[Identifier],
|
|
PO.[Key],
|
|
O.[PublicKey],
|
|
O.[PrivateKey],
|
|
PU.[Status],
|
|
PU.[Type],
|
|
PO.[ProviderId],
|
|
PU.[Id] ProviderUserId,
|
|
P.[Name] ProviderName,
|
|
O.[PlanType] -- new prop
|
|
FROM
|
|
[dbo].[ProviderUser] PU
|
|
INNER JOIN
|
|
[dbo].[ProviderOrganization] PO ON PO.[ProviderId] = PU.[ProviderId]
|
|
INNER JOIN
|
|
[dbo].[Organization] O ON O.[Id] = PO.[OrganizationId]
|
|
INNER JOIN
|
|
[dbo].[Provider] P ON P.[Id] = PU.[ProviderId]
|
|
GO
|
|
|
|
|
|
-- Refresh metadata of stored procs & functions that use the updated view
|
|
IF OBJECT_ID('[dbo].[ProviderUserProviderOrganizationDetails_ReadByUserIdStatus]') IS NOT NULL
|
|
BEGIN
|
|
EXECUTE sp_refreshsqlmodule N'[dbo].[ProviderUserProviderOrganizationDetails_ReadByUserIdStatus]';
|
|
END
|
|
GO
|
|
|
|
|
|
-- EC-591 / SG-996 changes: add optional status to stored proc
|
|
CREATE OR ALTER PROCEDURE [dbo].[ProviderUserUserDetails_ReadByProviderId]
|
|
@ProviderId UNIQUEIDENTIFIER,
|
|
@Status TINYINT = NULL -- new: this is required to be backwards compatible
|
|
AS
|
|
BEGIN
|
|
SET NOCOUNT ON
|
|
|
|
SELECT
|
|
*
|
|
FROM
|
|
[dbo].[ProviderUserUserDetailsView]
|
|
WHERE
|
|
[ProviderId] = @ProviderId
|
|
AND [Status] = COALESCE(@Status, [Status]) -- new
|
|
END
|
|
GO
|