1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-27 14:16:19 -05:00

fix(grantor-policies): [PM-21921] add null check (#5886)

When getting grantor policies, adds a null check so that:
- For a Grantor who is an org Owner, we respond with a `200` and the policies
- For a Grantor is not an org Owner, we respond with a `200` and `null`
This commit is contained in:
rr-bw 2025-06-25 09:30:51 -07:00 committed by GitHub
parent 2af4e9ccfa
commit 0f12d076ec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4,7 +4,6 @@ using Bit.Api.Auth.Models.Request;
using Bit.Api.Auth.Models.Response;
using Bit.Api.Models.Response;
using Bit.Api.Vault.Models.Response;
using Bit.Core.AdminConsole.Entities;
using Bit.Core.Auth.Services;
using Bit.Core.Exceptions;
using Bit.Core.Repositories;
@ -72,7 +71,7 @@ public class EmergencyAccessController : Controller
{
var user = await _userService.GetUserByPrincipalAsync(User);
var policies = await _emergencyAccessService.GetPoliciesAsync(id, user);
var responses = policies.Select<Policy, PolicyResponseModel>(policy => new PolicyResponseModel(policy));
var responses = policies?.Select(policy => new PolicyResponseModel(policy));
return new ListResponseModel<PolicyResponseModel>(responses);
}