mirror of
https://github.com/bitwarden/server.git
synced 2025-05-23 04:21:05 -05:00
Sent initiation path for organization and user signups (#3723)
This commit is contained in:
parent
56543722ad
commit
40a2a567e6
@ -48,6 +48,8 @@ public class OrganizationCreateRequestModel : IValidatableObject
|
|||||||
public bool UseSecretsManager { get; set; }
|
public bool UseSecretsManager { get; set; }
|
||||||
public bool IsFromSecretsManagerTrial { get; set; }
|
public bool IsFromSecretsManagerTrial { get; set; }
|
||||||
|
|
||||||
|
public string InitiationPath { get; set; }
|
||||||
|
|
||||||
public virtual OrganizationSignup ToOrganizationSignup(User user)
|
public virtual OrganizationSignup ToOrganizationSignup(User user)
|
||||||
{
|
{
|
||||||
var orgSignup = new OrganizationSignup
|
var orgSignup = new OrganizationSignup
|
||||||
@ -79,6 +81,7 @@ public class OrganizationCreateRequestModel : IValidatableObject
|
|||||||
BillingAddressPostalCode = BillingAddressPostalCode,
|
BillingAddressPostalCode = BillingAddressPostalCode,
|
||||||
BillingAddressCountry = BillingAddressCountry,
|
BillingAddressCountry = BillingAddressCountry,
|
||||||
},
|
},
|
||||||
|
InitiationPath = InitiationPath,
|
||||||
};
|
};
|
||||||
|
|
||||||
Keys?.ToOrganizationSignup(orgSignup);
|
Keys?.ToOrganizationSignup(orgSignup);
|
||||||
|
@ -533,6 +533,7 @@ public class OrganizationService : IOrganizationService
|
|||||||
PlanName = plan.Name,
|
PlanName = plan.Name,
|
||||||
PlanType = plan.Type,
|
PlanType = plan.Type,
|
||||||
Seats = returnValue.Item1.Seats,
|
Seats = returnValue.Item1.Seats,
|
||||||
|
SignupInitiationPath = signup.InitiationPath,
|
||||||
Storage = returnValue.Item1.MaxStorageGb,
|
Storage = returnValue.Item1.MaxStorageGb,
|
||||||
// TODO: add reference events for SmSeats and Service Accounts - see AC-1481
|
// TODO: add reference events for SmSeats and Service Accounts - see AC-1481
|
||||||
});
|
});
|
||||||
|
@ -13,4 +13,5 @@ public class OrganizationSignup : OrganizationUpgrade
|
|||||||
public PaymentMethodType? PaymentMethodType { get; set; }
|
public PaymentMethodType? PaymentMethodType { get; set; }
|
||||||
public string PaymentToken { get; set; }
|
public string PaymentToken { get; set; }
|
||||||
public int? MaxAutoscaleSeats { get; set; } = null;
|
public int? MaxAutoscaleSeats { get; set; } = null;
|
||||||
|
public string InitiationPath { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using System.Text.Json;
|
|
||||||
using Bit.Core.AdminConsole.Enums;
|
using Bit.Core.AdminConsole.Enums;
|
||||||
using Bit.Core.AdminConsole.Repositories;
|
using Bit.Core.AdminConsole.Repositories;
|
||||||
using Bit.Core.AdminConsole.Services;
|
using Bit.Core.AdminConsole.Services;
|
||||||
@ -28,7 +27,9 @@ using Microsoft.AspNetCore.DataProtection;
|
|||||||
using Microsoft.AspNetCore.Identity;
|
using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using File = System.IO.File;
|
using File = System.IO.File;
|
||||||
|
using JsonSerializer = System.Text.Json.JsonSerializer;
|
||||||
|
|
||||||
namespace Bit.Core.Services;
|
namespace Bit.Core.Services;
|
||||||
|
|
||||||
@ -338,6 +339,26 @@ public class UserService : UserManager<User>, IUserService, IDisposable
|
|||||||
if (result == IdentityResult.Success)
|
if (result == IdentityResult.Success)
|
||||||
{
|
{
|
||||||
await _mailService.SendWelcomeEmailAsync(user);
|
await _mailService.SendWelcomeEmailAsync(user);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(user.ReferenceData))
|
||||||
|
{
|
||||||
|
var referenceData = JsonConvert.DeserializeObject<Dictionary<string, object>>(user.ReferenceData);
|
||||||
|
if (referenceData.TryGetValue("initiationPath", out var value))
|
||||||
|
{
|
||||||
|
var initiationPath = value.ToString();
|
||||||
|
if (!string.IsNullOrEmpty(initiationPath))
|
||||||
|
{
|
||||||
|
await _referenceEventService.RaiseEventAsync(
|
||||||
|
new ReferenceEvent(ReferenceEventType.Signup, user, _currentContext)
|
||||||
|
{
|
||||||
|
SignupInitiationPath = initiationPath
|
||||||
|
});
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
await _referenceEventService.RaiseEventAsync(new ReferenceEvent(ReferenceEventType.Signup, user, _currentContext));
|
await _referenceEventService.RaiseEventAsync(new ReferenceEvent(ReferenceEventType.Signup, user, _currentContext));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,4 +234,13 @@ public class ReferenceEvent
|
|||||||
/// <see langword="null"/> when the event was not originated by an application.
|
/// <see langword="null"/> when the event was not originated by an application.
|
||||||
/// </value>
|
/// </value>
|
||||||
public Version? ClientVersion { get; set; }
|
public Version? ClientVersion { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The initiation path of a user who signed up for a paid version of Bitwarden. For example, "Trial from marketing website".
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// This value should only be populated when the <see cref="ReferenceEventType"/> is <see cref="ReferenceEventType.Signup"/>. Otherwise,
|
||||||
|
/// the value should be <see langword="null" />.
|
||||||
|
/// </value>
|
||||||
|
public string SignupInitiationPath { get; set; }
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user