mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 15:42:48 -05:00
[AC-2334] Fix unable to load members when permissions is "null" (#3922)
* Also add xmldoc comment to CoreHelpers.LoadClassFromJsonData to warn about this
This commit is contained in:
@ -94,8 +94,11 @@ public class OrganizationUsersController : Controller
|
||||
response.Type = GetFlexibleCollectionsUserType(response.Type, response.Permissions);
|
||||
|
||||
// Set 'Edit/Delete Assigned Collections' custom permissions to false
|
||||
response.Permissions.EditAssignedCollections = false;
|
||||
response.Permissions.DeleteAssignedCollections = false;
|
||||
if (response.Permissions is not null)
|
||||
{
|
||||
response.Permissions.EditAssignedCollections = false;
|
||||
response.Permissions.DeleteAssignedCollections = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (includeGroups)
|
||||
@ -552,8 +555,11 @@ public class OrganizationUsersController : Controller
|
||||
orgUser.Type = GetFlexibleCollectionsUserType(orgUser.Type, orgUser.Permissions);
|
||||
|
||||
// Set 'Edit/Delete Assigned Collections' custom permissions to false
|
||||
orgUser.Permissions.EditAssignedCollections = false;
|
||||
orgUser.Permissions.DeleteAssignedCollections = false;
|
||||
if (orgUser.Permissions is not null)
|
||||
{
|
||||
orgUser.Permissions.EditAssignedCollections = false;
|
||||
orgUser.Permissions.DeleteAssignedCollections = false;
|
||||
}
|
||||
|
||||
return orgUser;
|
||||
});
|
||||
@ -565,7 +571,7 @@ public class OrganizationUsersController : Controller
|
||||
private OrganizationUserType GetFlexibleCollectionsUserType(OrganizationUserType type, Permissions permissions)
|
||||
{
|
||||
// Downgrade Custom users with no other permissions than 'Edit/Delete Assigned Collections' to User
|
||||
if (type == OrganizationUserType.Custom)
|
||||
if (type == OrganizationUserType.Custom && permissions is not null)
|
||||
{
|
||||
if ((permissions.EditAssignedCollections || permissions.DeleteAssignedCollections) &&
|
||||
permissions is
|
||||
|
@ -74,7 +74,7 @@ public class ProfileOrganizationResponseModel : ResponseModel
|
||||
if (FlexibleCollections)
|
||||
{
|
||||
// Downgrade Custom users with no other permissions than 'Edit/Delete Assigned Collections' to User
|
||||
if (Type == OrganizationUserType.Custom)
|
||||
if (Type == OrganizationUserType.Custom && Permissions is not null)
|
||||
{
|
||||
if ((Permissions.EditAssignedCollections || Permissions.DeleteAssignedCollections) &&
|
||||
Permissions is
|
||||
@ -98,8 +98,11 @@ public class ProfileOrganizationResponseModel : ResponseModel
|
||||
}
|
||||
|
||||
// Set 'Edit/Delete Assigned Collections' custom permissions to false
|
||||
Permissions.EditAssignedCollections = false;
|
||||
Permissions.DeleteAssignedCollections = false;
|
||||
if (Permissions is not null)
|
||||
{
|
||||
Permissions.EditAssignedCollections = false;
|
||||
Permissions.DeleteAssignedCollections = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -763,6 +763,14 @@ public static class CoreHelpers
|
||||
return claims;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes JSON data into the specified type.
|
||||
/// If the JSON data is a null reference, it will still return an instantiated class.
|
||||
/// However, if the JSON data is a string "null", it will return null.
|
||||
/// </summary>
|
||||
/// <param name="jsonData">The JSON data</param>
|
||||
/// <typeparam name="T">The type to deserialize into</typeparam>
|
||||
/// <returns></returns>
|
||||
public static T LoadClassFromJsonData<T>(string jsonData) where T : new()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(jsonData))
|
||||
|
Reference in New Issue
Block a user