mirror of
https://github.com/bitwarden/server.git
synced 2025-01-27 22:41:22 +01:00
[SM-502] Fix Users with no name (#2698)
* Return email if username is empty
This commit is contained in:
parent
f288787a45
commit
bcc2a2a1ce
@ -1,4 +1,5 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
|
using Bit.Core.Entities;
|
||||||
using Bit.Core.Models.Api;
|
using Bit.Core.Models.Api;
|
||||||
using Bit.Core.SecretsManager.Entities;
|
using Bit.Core.SecretsManager.Entities;
|
||||||
|
|
||||||
@ -20,6 +21,11 @@ public abstract class BaseAccessPolicyResponseModel : ResponseModel
|
|||||||
public bool Write { get; set; }
|
public bool Write { get; set; }
|
||||||
public DateTime CreationDate { get; set; }
|
public DateTime CreationDate { get; set; }
|
||||||
public DateTime RevisionDate { get; set; }
|
public DateTime RevisionDate { get; set; }
|
||||||
|
|
||||||
|
public string? GetUserDisplayName(User? user)
|
||||||
|
{
|
||||||
|
return string.IsNullOrWhiteSpace(user?.Name) ? user?.Email : user?.Name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class UserProjectAccessPolicyResponseModel : BaseAccessPolicyResponseModel
|
public class UserProjectAccessPolicyResponseModel : BaseAccessPolicyResponseModel
|
||||||
@ -30,7 +36,7 @@ public class UserProjectAccessPolicyResponseModel : BaseAccessPolicyResponseMode
|
|||||||
{
|
{
|
||||||
OrganizationUserId = accessPolicy.OrganizationUserId;
|
OrganizationUserId = accessPolicy.OrganizationUserId;
|
||||||
GrantedProjectId = accessPolicy.GrantedProjectId;
|
GrantedProjectId = accessPolicy.GrantedProjectId;
|
||||||
OrganizationUserName = accessPolicy.User?.Name;
|
OrganizationUserName = GetUserDisplayName(accessPolicy.User);
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserProjectAccessPolicyResponseModel() : base(new UserProjectAccessPolicy(), _objectName)
|
public UserProjectAccessPolicyResponseModel() : base(new UserProjectAccessPolicy(), _objectName)
|
||||||
@ -51,7 +57,7 @@ public class UserServiceAccountAccessPolicyResponseModel : BaseAccessPolicyRespo
|
|||||||
{
|
{
|
||||||
OrganizationUserId = accessPolicy.OrganizationUserId;
|
OrganizationUserId = accessPolicy.OrganizationUserId;
|
||||||
GrantedServiceAccountId = accessPolicy.GrantedServiceAccountId;
|
GrantedServiceAccountId = accessPolicy.GrantedServiceAccountId;
|
||||||
OrganizationUserName = accessPolicy.User?.Name;
|
OrganizationUserName = GetUserDisplayName(accessPolicy.User);
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserServiceAccountAccessPolicyResponseModel() : base(new UserServiceAccountAccessPolicy(), _objectName)
|
public UserServiceAccountAccessPolicyResponseModel() : base(new UserServiceAccountAccessPolicy(), _objectName)
|
||||||
|
Loading…
Reference in New Issue
Block a user