Skip to content

Commit

Permalink
[PM-14876] Update admin panel copy from 'Domain Verified' to 'Claimed…
Browse files Browse the repository at this point in the history
… Account' and rename associated ViewModel properties (#5058)
  • Loading branch information
r-tome authored Nov 27, 2024
1 parent c8930d4 commit aa364ca
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 27 deletions.
10 changes: 3 additions & 7 deletions src/Admin/Models/UserEditModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ namespace Bit.Admin.Models;

public class UserEditModel
{
public UserEditModel()
{

}
public UserEditModel() { }

public UserEditModel(
User user,
Expand All @@ -21,10 +18,9 @@ public UserEditModel(
BillingInfo billingInfo,
BillingHistoryInfo billingHistoryInfo,
GlobalSettings globalSettings,
bool? domainVerified
)
bool? claimedAccount)
{
User = UserViewModel.MapViewModel(user, isTwoFactorEnabled, ciphers, domainVerified);
User = UserViewModel.MapViewModel(user, isTwoFactorEnabled, ciphers, claimedAccount);

BillingInfo = billingInfo;
BillingHistoryInfo = billingHistoryInfo;
Expand Down
14 changes: 7 additions & 7 deletions src/Admin/Models/UserViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class UserViewModel
public bool Premium { get; }
public short? MaxStorageGb { get; }
public bool EmailVerified { get; }
public bool? DomainVerified { get; }
public bool? ClaimedAccount { get; }
public bool TwoFactorEnabled { get; }
public DateTime AccountRevisionDate { get; }
public DateTime RevisionDate { get; }
Expand All @@ -36,7 +36,7 @@ public UserViewModel(Guid id,
bool premium,
short? maxStorageGb,
bool emailVerified,
bool? domainVerified,
bool? claimedAccount,
bool twoFactorEnabled,
DateTime accountRevisionDate,
DateTime revisionDate,
Expand All @@ -58,7 +58,7 @@ public UserViewModel(Guid id,
Premium = premium;
MaxStorageGb = maxStorageGb;
EmailVerified = emailVerified;
DomainVerified = domainVerified;
ClaimedAccount = claimedAccount;
TwoFactorEnabled = twoFactorEnabled;
AccountRevisionDate = accountRevisionDate;
RevisionDate = revisionDate;
Expand All @@ -79,7 +79,7 @@ public static IEnumerable<UserViewModel> MapViewModels(
users.Select(user => MapViewModel(user, lookup, false));

public static UserViewModel MapViewModel(User user,
IEnumerable<(Guid userId, bool twoFactorIsEnabled)> lookup, bool? domainVerified) =>
IEnumerable<(Guid userId, bool twoFactorIsEnabled)> lookup, bool? claimedAccount) =>
new(
user.Id,
user.Name,
Expand All @@ -89,7 +89,7 @@ public static UserViewModel MapViewModel(User user,
user.Premium,
user.MaxStorageGb,
user.EmailVerified,
domainVerified,
claimedAccount,
IsTwoFactorEnabled(user, lookup),
user.AccountRevisionDate,
user.RevisionDate,
Expand All @@ -106,7 +106,7 @@ public static UserViewModel MapViewModel(User user,
public static UserViewModel MapViewModel(User user, bool isTwoFactorEnabled) =>
MapViewModel(user, isTwoFactorEnabled, Array.Empty<Cipher>(), false);

public static UserViewModel MapViewModel(User user, bool isTwoFactorEnabled, IEnumerable<Cipher> ciphers, bool? domainVerified) =>
public static UserViewModel MapViewModel(User user, bool isTwoFactorEnabled, IEnumerable<Cipher> ciphers, bool? claimedAccount) =>
new(
user.Id,
user.Name,
Expand All @@ -116,7 +116,7 @@ public static UserViewModel MapViewModel(User user, bool isTwoFactorEnabled, IEn
user.Premium,
user.MaxStorageGb,
user.EmailVerified,
domainVerified,
claimedAccount,
isTwoFactorEnabled,
user.AccountRevisionDate,
user.RevisionDate,
Expand Down
7 changes: 4 additions & 3 deletions src/Admin/Views/Users/_ViewInformation.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
<dt class="col-sm-4 col-lg-3">Email Verified</dt>
<dd class="col-sm-8 col-lg-9">@(Model.EmailVerified ? "Yes" : "No")</dd>

@if(Model.DomainVerified.HasValue){
<dt class="col-sm-4 col-lg-3">Domain Verified</dt>
<dd class="col-sm-8 col-lg-9">@(Model.DomainVerified.Value == true ? "Yes" : "No")</dd>
@if(Model.ClaimedAccount.HasValue)
{
<dt class="col-sm-4 col-lg-3">Claimed Account</dt>
<dd class="col-sm-8 col-lg-9">@(Model.ClaimedAccount.Value ? "Yes" : "No")</dd>
}

<dt class="col-sm-4 col-lg-3">Using 2FA</dt>
Expand Down
14 changes: 4 additions & 10 deletions test/Admin.Test/Models/UserViewModelTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#nullable enable

using Bit.Admin.Models;
using Bit.Admin.Models;
using Bit.Core.Entities;
using Bit.Core.Vault.Entities;
using Bit.Test.Common.AutoFixture.Attributes;
Expand Down Expand Up @@ -116,30 +114,26 @@ public void MapUserViewModel_WithVerifiedDomain_ReturnsUserViewModel(User user)

var actual = UserViewModel.MapViewModel(user, true, Array.Empty<Cipher>(), verifiedDomain);

Assert.True(actual.DomainVerified);
Assert.True(actual.ClaimedAccount);
}

[Theory]
[BitAutoData]
public void MapUserViewModel_WithoutVerifiedDomain_ReturnsUserViewModel(User user)
{

var verifiedDomain = false;

var actual = UserViewModel.MapViewModel(user, true, Array.Empty<Cipher>(), verifiedDomain);

Assert.False(actual.DomainVerified);
Assert.False(actual.ClaimedAccount);
}

[Theory]
[BitAutoData]
public void MapUserViewModel_WithNullVerifiedDomain_ReturnsUserViewModel(User user)
{

var actual = UserViewModel.MapViewModel(user, true, Array.Empty<Cipher>(), null);

Assert.Null(actual.DomainVerified);
Assert.Null(actual.ClaimedAccount);
}


}

0 comments on commit aa364ca

Please sign in to comment.