Skip to content

Commit

Permalink
[AC-1487] Update queries to use [User] table instead of [Organization…
Browse files Browse the repository at this point in the history
…User] for email address (#3083)
  • Loading branch information
shane-melton authored Jul 17, 2023
1 parent 4f87e4e commit fe570cb
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ BEGIN
SET NOCOUNT ON

SELECT
ar.*, ou.[Email], ou.[Id] AS [OrganizationUserId]
ar.*, u.[Email], ou.[Id] AS [OrganizationUserId]
FROM
[dbo].[AuthRequestView] ar
INNER JOIN
[dbo].[OrganizationUser] ou ON ou.[UserId] = ar.[UserId] AND ou.[OrganizationId] = ar.[OrganizationId]
INNER JOIN
[dbo].[User] u ON u.[Id] = ar.[UserId]
WHERE
ar.[OrganizationId] = @OrganizationId
AND
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ BEGIN
SET NOCOUNT ON

SELECT
ar.*, ou.[Email], ou.[OrganizationId], ou.[Id] AS [OrganizationUserId]
ar.*, u.[Email], ou.[Id] AS [OrganizationUserId]
FROM
[dbo].[AuthRequestView] ar
INNER JOIN
[dbo].[OrganizationUser] ou ON ou.[UserId] = ar.[UserId] AND ou.[OrganizationId] = ar.[OrganizationId]
INNER JOIN
[dbo].[User] u ON u.[Id] = ar.[UserId]
WHERE
ar.[OrganizationId] = @OrganizationId
AND
Expand Down
46 changes: 46 additions & 0 deletions util/Migrator/DbScripts/2023-07-10_00_FixTdeAdminApprovalEmail.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
CREATE OR ALTER PROCEDURE [dbo].[AuthRequest_ReadAdminApprovalsByIds]
@OrganizationId UNIQUEIDENTIFIER,
@Ids AS [dbo].[GuidIdArray] READONLY
AS
BEGIN
SET NOCOUNT ON

SELECT
ar.*, u.[Email], ou.[Id] AS [OrganizationUserId]
FROM
[dbo].[AuthRequestView] ar
INNER JOIN
[dbo].[OrganizationUser] ou ON ou.[UserId] = ar.[UserId] AND ou.[OrganizationId] = ar.[OrganizationId]
INNER JOIN
[dbo].[User] u ON u.[Id] = ar.[UserId]
WHERE
ar.[OrganizationId] = @OrganizationId
AND
ar.[Type] = 2 -- AdminApproval
AND
ar.[Id] IN (SELECT [Id] FROM @Ids)
END
GO

CREATE OR ALTER PROCEDURE [dbo].[AuthRequest_ReadPendingByOrganizationId]
@OrganizationId UNIQUEIDENTIFIER
AS
BEGIN
SET NOCOUNT ON

SELECT
ar.*, u.[Email], ou.[Id] AS [OrganizationUserId]
FROM
[dbo].[AuthRequestView] ar
INNER JOIN
[dbo].[OrganizationUser] ou ON ou.[UserId] = ar.[UserId] AND ou.[OrganizationId] = ar.[OrganizationId]
INNER JOIN
[dbo].[User] u ON u.[Id] = ar.[UserId]
WHERE
ar.[OrganizationId] = @OrganizationId
AND
ar.[ResponseDate] IS NULL
AND
ar.[Type] = 2 -- AdminApproval
END
GO

0 comments on commit fe570cb

Please sign in to comment.