mirror of
https://github.com/bitwarden/server.git
synced 2025-05-17 17:45:36 -05:00
fix(RegistrationViaOrgInviteWelcomeEmail): [Auth/PM-21428] Registration via Org Invite should send welcome email even if reference data isn't provided (#5796)
This commit is contained in:
parent
dd2ea41b74
commit
9ebe165871
@ -108,6 +108,7 @@ public class RegisterUserCommand : IRegisterUserCommand
|
|||||||
var result = await _userService.CreateUserAsync(user, masterPasswordHash);
|
var result = await _userService.CreateUserAsync(user, masterPasswordHash);
|
||||||
if (result == IdentityResult.Success)
|
if (result == IdentityResult.Success)
|
||||||
{
|
{
|
||||||
|
var sentWelcomeEmail = false;
|
||||||
if (!string.IsNullOrEmpty(user.ReferenceData))
|
if (!string.IsNullOrEmpty(user.ReferenceData))
|
||||||
{
|
{
|
||||||
var referenceData = JsonConvert.DeserializeObject<Dictionary<string, object>>(user.ReferenceData);
|
var referenceData = JsonConvert.DeserializeObject<Dictionary<string, object>>(user.ReferenceData);
|
||||||
@ -115,6 +116,7 @@ public class RegisterUserCommand : IRegisterUserCommand
|
|||||||
{
|
{
|
||||||
var initiationPath = value.ToString();
|
var initiationPath = value.ToString();
|
||||||
await SendAppropriateWelcomeEmailAsync(user, initiationPath);
|
await SendAppropriateWelcomeEmailAsync(user, initiationPath);
|
||||||
|
sentWelcomeEmail = true;
|
||||||
if (!string.IsNullOrEmpty(initiationPath))
|
if (!string.IsNullOrEmpty(initiationPath))
|
||||||
{
|
{
|
||||||
await _referenceEventService.RaiseEventAsync(
|
await _referenceEventService.RaiseEventAsync(
|
||||||
@ -128,6 +130,11 @@ public class RegisterUserCommand : IRegisterUserCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!sentWelcomeEmail)
|
||||||
|
{
|
||||||
|
await _mailService.SendWelcomeEmailAsync(user);
|
||||||
|
}
|
||||||
|
|
||||||
await _referenceEventService.RaiseEventAsync(new ReferenceEvent(ReferenceEventType.Signup, user, _currentContext));
|
await _referenceEventService.RaiseEventAsync(new ReferenceEvent(ReferenceEventType.Signup, user, _currentContext));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,6 +226,11 @@ public class RegisterUserCommandTests
|
|||||||
await sutProvider.GetDependency<IReferenceEventService>()
|
await sutProvider.GetDependency<IReferenceEventService>()
|
||||||
.Received(1)
|
.Received(1)
|
||||||
.RaiseEventAsync(Arg.Is<ReferenceEvent>(refEvent => refEvent.Type == ReferenceEventType.Signup && refEvent.SignupInitiationPath == default));
|
.RaiseEventAsync(Arg.Is<ReferenceEvent>(refEvent => refEvent.Type == ReferenceEventType.Signup && refEvent.SignupInitiationPath == default));
|
||||||
|
|
||||||
|
// Even if user doesn't have reference data, we should send them welcome email
|
||||||
|
await sutProvider.GetDependency<IMailService>()
|
||||||
|
.Received(1)
|
||||||
|
.SendWelcomeEmailAsync(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.True(result.Succeeded);
|
Assert.True(result.Succeeded);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user