1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-25 13:18:48 -05:00

fix: rename parameter to be clearer and changed order of parameters in constructor.

This commit is contained in:
Ike Kottlowski 2025-06-23 21:57:17 -04:00
parent be3ccc3ff0
commit 943b0024bb
No known key found for this signature in database
GPG Key ID: C86308E3DCA6D76F
3 changed files with 13 additions and 12 deletions

View File

@ -8,8 +8,8 @@ public class PendingAuthRequestResponseModel : AuthRequestResponseModel
: base(authRequest, vaultUri, obj)
{
ArgumentNullException.ThrowIfNull(authRequest);
RequestingDeviceId = authRequest.DeviceId;
RequestDeviceId = authRequest.RequestDeviceId;
}
public Guid? RequestingDeviceId { get; set; }
public Guid? RequestDeviceId { get; set; }
}

View File

@ -7,7 +7,7 @@ namespace Bit.Core.Auth.Models.Data;
public class PendingAuthRequestDetails : AuthRequest
{
public Guid? DeviceId { get; set; }
public Guid? RequestDeviceId { get; set; }
/**
* Constructor for EF response.
@ -35,16 +35,17 @@ public class PendingAuthRequestDetails : AuthRequest
CreationDate = authRequest.CreationDate;
ResponseDate = authRequest.ResponseDate;
AuthenticationDate = authRequest.AuthenticationDate;
DeviceId = deviceId;
RequestDeviceId = deviceId;
}
/**
* Constructor for dapper response.
* Note: if the DeviceId is null it comes back as an empty guid That could change if the stored
* procedure runs on a different kind of db.
* In order to maintain the flexibility of the wildcard * in SQL the constrctor accepts a long "row number rn"
* parameter that was used to order the results in the SQL query. Also SQL complains about the constructor not
* having the same parameters as the SELECT statement.
* procedure runs on a different database provider.
* In order to maintain the flexibility of the wildcard (*) in SQL, the constructor accepts a"row number" rn of type long
* parameter. 'rn' was used to order the results in the SQL query. Also, SQL complains about the constructor not
* having the same parameters as the SELECT statement and since the SELECT uses the wildcard we need to include everything.
* Order matters when mapping from the Stored Procedure, so the columns are in the order they come back from the query.
*/
public PendingAuthRequestDetails(
Guid id,
@ -69,12 +70,10 @@ public class PendingAuthRequestDetails : AuthRequest
{
Id = id;
UserId = userId;
OrganizationId = organizationId;
Type = (AuthRequestType)type;
RequestDeviceIdentifier = requestDeviceIdentifier;
RequestDeviceType = (DeviceType)requestDeviceType;
RequestIpAddress = requestIpAddress;
RequestCountryName = requestCountryName;
ResponseDeviceId = responseDeviceId;
AccessCode = accessCode;
PublicKey = publicKey;
@ -84,6 +83,8 @@ public class PendingAuthRequestDetails : AuthRequest
CreationDate = creationDate;
ResponseDate = responseDate;
AuthenticationDate = authenticationDate;
DeviceId = deviceId;
OrganizationId = organizationId;
RequestCountryName = requestCountryName;
RequestDeviceId = deviceId;
}
}

View File

@ -77,7 +77,7 @@ public class AuthRequestRepository : Repository<Core.Auth.Entities.AuthRequest,
select
(from r in groupedAuthRequests
join d in dbContext.Devices on r.RequestDeviceIdentifier equals d.Identifier into deviceJoin
from dj in deviceJoin.DefaultIfEmpty() // This accomplishes a left join allowing nulld for devices
from dj in deviceJoin.DefaultIfEmpty() // This creates a left join allowing null for devices
orderby r.CreationDate descending
select new PendingAuthRequestDetails(r, dj.Id)).First()
).ToListAsync();