2022-06-29 19:46:41 -04:00
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
2024-06-11 13:55:23 -04:00
|
|
|
|
using Bit.Core.Billing.Models;
|
2022-01-11 10:40:51 +01:00
|
|
|
|
using Bit.Core.Entities;
|
2021-02-22 15:35:16 -06:00
|
|
|
|
using Bit.Core.Settings;
|
2018-03-22 17:33:22 -04:00
|
|
|
|
using Bit.Core.Utilities;
|
2023-03-02 13:23:38 -05:00
|
|
|
|
using Bit.Core.Vault.Entities;
|
2018-03-22 15:50:56 -04:00
|
|
|
|
|
|
|
|
|
|
namespace Bit.Admin.Models;
|
2022-08-29 16:06:55 -04:00
|
|
|
|
|
2024-09-30 13:21:30 -05:00
|
|
|
|
public class UserEditModel
|
2018-03-22 15:50:56 -04:00
|
|
|
|
{
|
2024-09-30 13:21:30 -05:00
|
|
|
|
public UserEditModel()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2018-03-22 17:33:22 -04:00
|
|
|
|
|
2024-06-11 13:55:23 -04:00
|
|
|
|
public UserEditModel(
|
|
|
|
|
|
User user,
|
2024-09-30 13:21:30 -05:00
|
|
|
|
bool isTwoFactorEnabled,
|
2024-06-11 13:55:23 -04:00
|
|
|
|
IEnumerable<Cipher> ciphers,
|
|
|
|
|
|
BillingInfo billingInfo,
|
|
|
|
|
|
BillingHistoryInfo billingHistoryInfo,
|
2018-03-22 15:50:56 -04:00
|
|
|
|
GlobalSettings globalSettings)
|
2022-08-29 15:53:48 -04:00
|
|
|
|
{
|
2024-09-30 13:21:30 -05:00
|
|
|
|
User = UserViewModel.MapViewModel(user, isTwoFactorEnabled, ciphers);
|
|
|
|
|
|
|
2018-03-22 15:50:56 -04:00
|
|
|
|
BillingInfo = billingInfo;
|
2024-06-11 13:55:23 -04:00
|
|
|
|
BillingHistoryInfo = billingHistoryInfo;
|
2018-03-22 15:50:56 -04:00
|
|
|
|
BraintreeMerchantId = globalSettings.Braintree.MerchantId;
|
2021-12-16 15:35:09 +01:00
|
|
|
|
|
2019-02-25 10:39:04 -05:00
|
|
|
|
Name = user.Name;
|
|
|
|
|
|
Email = user.Email;
|
2018-03-22 15:50:56 -04:00
|
|
|
|
EmailVerified = user.EmailVerified;
|
2018-03-22 17:33:22 -04:00
|
|
|
|
Premium = user.Premium;
|
|
|
|
|
|
MaxStorageGb = user.MaxStorageGb;
|
2018-03-22 15:50:56 -04:00
|
|
|
|
Gateway = user.Gateway;
|
2018-03-22 17:33:22 -04:00
|
|
|
|
GatewayCustomerId = user.GatewayCustomerId;
|
|
|
|
|
|
GatewaySubscriptionId = user.GatewaySubscriptionId;
|
|
|
|
|
|
LicenseKey = user.LicenseKey;
|
|
|
|
|
|
PremiumExpirationDate = user.PremiumExpirationDate;
|
|
|
|
|
|
}
|
2018-03-22 15:50:56 -04:00
|
|
|
|
|
2024-09-30 13:21:30 -05:00
|
|
|
|
public UserViewModel User { get; init; }
|
|
|
|
|
|
public BillingInfo BillingInfo { get; init; }
|
|
|
|
|
|
public BillingHistoryInfo BillingHistoryInfo { get; init; }
|
2018-03-22 15:50:56 -04:00
|
|
|
|
public string RandomLicenseKey => CoreHelpers.SecureRandomString(20);
|
|
|
|
|
|
public string OneYearExpirationDate => DateTime.Now.AddYears(1).ToString("yyyy-MM-ddTHH:mm");
|
2024-09-30 13:21:30 -05:00
|
|
|
|
public string BraintreeMerchantId { get; init; }
|
2018-03-22 15:50:56 -04:00
|
|
|
|
|
|
|
|
|
|
[Display(Name = "Name")]
|
2024-09-30 13:21:30 -05:00
|
|
|
|
public string Name { get; init; }
|
2018-03-22 15:50:56 -04:00
|
|
|
|
[Required]
|
|
|
|
|
|
[Display(Name = "Email")]
|
2024-09-30 13:21:30 -05:00
|
|
|
|
public string Email { get; init; }
|
2018-03-22 15:50:56 -04:00
|
|
|
|
[Display(Name = "Email Verified")]
|
2024-09-30 13:21:30 -05:00
|
|
|
|
public bool EmailVerified { get; init; }
|
2018-03-22 15:50:56 -04:00
|
|
|
|
[Display(Name = "Premium")]
|
2024-09-30 13:21:30 -05:00
|
|
|
|
public bool Premium { get; init; }
|
2018-03-22 15:50:56 -04:00
|
|
|
|
[Display(Name = "Max. Storage GB")]
|
2024-09-30 13:21:30 -05:00
|
|
|
|
public short? MaxStorageGb { get; init; }
|
2018-03-22 15:50:56 -04:00
|
|
|
|
[Display(Name = "Gateway")]
|
2024-09-30 13:21:30 -05:00
|
|
|
|
public Core.Enums.GatewayType? Gateway { get; init; }
|
2018-03-22 15:50:56 -04:00
|
|
|
|
[Display(Name = "Gateway Customer Id")]
|
2024-09-30 13:21:30 -05:00
|
|
|
|
public string GatewayCustomerId { get; init; }
|
2018-03-22 15:50:56 -04:00
|
|
|
|
[Display(Name = "Gateway Subscription Id")]
|
2024-09-30 13:21:30 -05:00
|
|
|
|
public string GatewaySubscriptionId { get; init; }
|
2018-03-22 15:50:56 -04:00
|
|
|
|
[Display(Name = "License Key")]
|
2024-09-30 13:21:30 -05:00
|
|
|
|
public string LicenseKey { get; init; }
|
2018-03-22 15:50:56 -04:00
|
|
|
|
[Display(Name = "Premium Expiration Date")]
|
2024-09-30 13:21:30 -05:00
|
|
|
|
public DateTime? PremiumExpirationDate { get; init; }
|
2018-03-22 15:50:56 -04:00
|
|
|
|
}
|