mirror of
https://github.com/bitwarden/server
synced 2025-12-06 00:03:34 +00:00
Auth/pm 25453/support n users auth request (#6347)
* fix(pending-auth-request-view): [PM-25453] Bugfix Auth Requests Multiple Users Same Device - fixed view to allow for multiple users for each device when partitioning for the auth request view.
This commit is contained in:
committed by
GitHub
parent
d83395aeb0
commit
26e574e8d7
@@ -7,7 +7,7 @@ AS
|
||||
SELECT
|
||||
[AR].*,
|
||||
[D].[Id] AS [DeviceId],
|
||||
ROW_NUMBER() OVER (PARTITION BY [AR].[RequestDeviceIdentifier] ORDER BY [AR].[CreationDate] DESC) AS [rn]
|
||||
ROW_NUMBER() OVER (PARTITION BY [AR].[RequestDeviceIdentifier], [AR].[UserId] ORDER BY [AR].[CreationDate] DESC) AS [rn]
|
||||
FROM [dbo].[AuthRequest] [AR]
|
||||
LEFT JOIN [dbo].[Device] [D]
|
||||
ON [AR].[RequestDeviceIdentifier] = [D].[Identifier]
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
CREATE OR ALTER VIEW [dbo].[AuthRequestPendingDetailsView]
|
||||
AS
|
||||
WITH
|
||||
PendingRequests
|
||||
AS
|
||||
(
|
||||
SELECT
|
||||
[AR].*,
|
||||
[D].[Id] AS [DeviceId],
|
||||
ROW_NUMBER() OVER (PARTITION BY [AR].[RequestDeviceIdentifier], [AR].[UserId] ORDER BY [AR].[CreationDate] DESC) AS [rn]
|
||||
FROM [dbo].[AuthRequest] [AR]
|
||||
LEFT JOIN [dbo].[Device] [D]
|
||||
ON [AR].[RequestDeviceIdentifier] = [D].[Identifier]
|
||||
AND [D].[UserId] = [AR].[UserId]
|
||||
WHERE [AR].[Type] IN (0, 1) -- 0 = AuthenticateAndUnlock, 1 = Unlock
|
||||
)
|
||||
SELECT
|
||||
[PR].[Id],
|
||||
[PR].[UserId],
|
||||
[PR].[OrganizationId],
|
||||
[PR].[Type],
|
||||
[PR].[RequestDeviceIdentifier],
|
||||
[PR].[RequestDeviceType],
|
||||
[PR].[RequestIpAddress],
|
||||
[PR].[RequestCountryName],
|
||||
[PR].[ResponseDeviceId],
|
||||
[PR].[AccessCode],
|
||||
[PR].[PublicKey],
|
||||
[PR].[Key],
|
||||
[PR].[MasterPasswordHash],
|
||||
[PR].[Approved],
|
||||
[PR].[CreationDate],
|
||||
[PR].[ResponseDate],
|
||||
[PR].[AuthenticationDate],
|
||||
[PR].[DeviceId]
|
||||
FROM [PendingRequests] [PR]
|
||||
WHERE [PR].[rn] = 1
|
||||
AND [PR].[Approved] IS NULL -- since we only want pending requests we only want the most recent that is also approved = null
|
||||
GO
|
||||
|
||||
EXECUTE sp_refreshsqlmodule N'[dbo].[AuthRequestPendingDetailsView]'
|
||||
GO
|
||||
Reference in New Issue
Block a user