From 072fb727a8b65d596ce218cc7fe8fb485111125d Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Thu, 23 Mar 2017 16:56:25 -0400 Subject: [PATCH] org user invite emails --- src/Api/settings.Production.json | 6 +++--- src/Api/settings.Staging.json | 6 +++--- src/Api/settings.json | 2 +- src/Core/Services/IMailService.cs | 2 +- src/Core/Services/Implementations/NoopMailService.cs | 2 +- src/Core/Services/Implementations/OrganizationService.cs | 4 ++-- src/Core/Services/Implementations/SendGridMailService.cs | 6 ++++-- 7 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/Api/settings.Production.json b/src/Api/settings.Production.json index 040bb384ef..8cb3e0000a 100644 --- a/src/Api/settings.Production.json +++ b/src/Api/settings.Production.json @@ -1,5 +1,5 @@ { - "globalSettings": { - "baseVaultUri": "https://vault.bitwarden.com" - } + "globalSettings": { + "baseVaultUri": "https://vault.bitwarden.com/#" + } } diff --git a/src/Api/settings.Staging.json b/src/Api/settings.Staging.json index 040bb384ef..8cb3e0000a 100644 --- a/src/Api/settings.Staging.json +++ b/src/Api/settings.Staging.json @@ -1,5 +1,5 @@ { - "globalSettings": { - "baseVaultUri": "https://vault.bitwarden.com" - } + "globalSettings": { + "baseVaultUri": "https://vault.bitwarden.com/#" + } } diff --git a/src/Api/settings.json b/src/Api/settings.json index 4ee2f20ce9..8384bbe8a6 100644 --- a/src/Api/settings.json +++ b/src/Api/settings.json @@ -1,7 +1,7 @@ { "globalSettings": { "siteName": "bitwarden", - "baseVaultUri": "http://localhost:4001", + "baseVaultUri": "http://localhost:4001/#", "jwtSigningKey": "THIS IS A SECRET. IT KEEPS YOUR TOKEN SAFE. :)", "sqlServer": { "connectionString": "SECRET" diff --git a/src/Core/Services/IMailService.cs b/src/Core/Services/IMailService.cs index cfe737b8e2..d1a85ff404 100644 --- a/src/Core/Services/IMailService.cs +++ b/src/Core/Services/IMailService.cs @@ -10,6 +10,6 @@ namespace Bit.Core.Services Task SendChangeEmailEmailAsync(string newEmailAddress, string token); Task SendNoMasterPasswordHintEmailAsync(string email); Task SendMasterPasswordHintEmailAsync(string email, string hint); - Task SendOrganizationInviteEmailAsync(string organizationName, string email, string token); + Task SendOrganizationInviteEmailAsync(string organizationName, OrganizationUser orgUser, string token); } } \ No newline at end of file diff --git a/src/Core/Services/Implementations/NoopMailService.cs b/src/Core/Services/Implementations/NoopMailService.cs index 988e067ce3..50cb74cc50 100644 --- a/src/Core/Services/Implementations/NoopMailService.cs +++ b/src/Core/Services/Implementations/NoopMailService.cs @@ -26,7 +26,7 @@ namespace Bit.Core.Services return Task.FromResult(0); } - public Task SendOrganizationInviteEmailAsync(string organizationName, string email, string token) + public Task SendOrganizationInviteEmailAsync(string organizationName, OrganizationUser orgUser, string token) { return Task.FromResult(0); } diff --git a/src/Core/Services/Implementations/OrganizationService.cs b/src/Core/Services/Implementations/OrganizationService.cs index e2e4443a87..b5eb578f85 100644 --- a/src/Core/Services/Implementations/OrganizationService.cs +++ b/src/Core/Services/Implementations/OrganizationService.cs @@ -150,7 +150,7 @@ namespace Bit.Core.Services var nowMillis = CoreHelpers.ToEpocMilliseconds(DateTime.UtcNow); var token = _dataProtector.Protect( $"OrganizationUserInvite {orgUser.Id} {orgUser.Email} {nowMillis}"); - await _mailService.SendOrganizationInviteEmailAsync("Organization Name", orgUser.Email, token); + await _mailService.SendOrganizationInviteEmailAsync("Organization Name", orgUser, token); } public async Task AcceptUserAsync(Guid organizationUserId, User user, string token) @@ -189,7 +189,7 @@ namespace Bit.Core.Services } orgUser.Status = Enums.OrganizationUserStatusType.Accepted; - orgUser.UserId = orgUser.Id; + orgUser.UserId = user.Id; orgUser.Email = null; await _organizationUserRepository.ReplaceAsync(orgUser); diff --git a/src/Core/Services/Implementations/SendGridMailService.cs b/src/Core/Services/Implementations/SendGridMailService.cs index 930c83ef29..f972f608c9 100644 --- a/src/Core/Services/Implementations/SendGridMailService.cs +++ b/src/Core/Services/Implementations/SendGridMailService.cs @@ -88,13 +88,15 @@ namespace Bit.Core.Services await _client.SendEmailAsync(message); } - public async Task SendOrganizationInviteEmailAsync(string organizationName, string email, string token) + public async Task SendOrganizationInviteEmailAsync(string organizationName, OrganizationUser orgUser, string token) { var message = CreateDefaultMessage(OrganizationInviteTemplateId); message.Subject = $"Join {organizationName}"; - message.AddTo(new EmailAddress(email)); + message.AddTo(new EmailAddress(orgUser.Email)); message.AddSubstitution("{{organizationName}}", organizationName); + message.AddSubstitution("{{organizationId}}", orgUser.OrganizationId.ToString()); + message.AddSubstitution("{{organizationUserId}}", orgUser.Id.ToString()); message.AddSubstitution("{{token}}", token); message.AddCategories(new List { AdministrativeCategoryName, "Organization Invite" });