1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-06 21:48:12 -05:00

org user invite emails

This commit is contained in:
Kyle Spearrin 2017-03-23 16:56:25 -04:00
parent 4eac3694a3
commit 072fb727a8
7 changed files with 15 additions and 13 deletions

View File

@ -1,5 +1,5 @@
{ {
"globalSettings": { "globalSettings": {
"baseVaultUri": "https://vault.bitwarden.com" "baseVaultUri": "https://vault.bitwarden.com/#"
} }
} }

View File

@ -1,5 +1,5 @@
{ {
"globalSettings": { "globalSettings": {
"baseVaultUri": "https://vault.bitwarden.com" "baseVaultUri": "https://vault.bitwarden.com/#"
} }
} }

View File

@ -1,7 +1,7 @@
{ {
"globalSettings": { "globalSettings": {
"siteName": "bitwarden", "siteName": "bitwarden",
"baseVaultUri": "http://localhost:4001", "baseVaultUri": "http://localhost:4001/#",
"jwtSigningKey": "THIS IS A SECRET. IT KEEPS YOUR TOKEN SAFE. :)", "jwtSigningKey": "THIS IS A SECRET. IT KEEPS YOUR TOKEN SAFE. :)",
"sqlServer": { "sqlServer": {
"connectionString": "SECRET" "connectionString": "SECRET"

View File

@ -10,6 +10,6 @@ namespace Bit.Core.Services
Task SendChangeEmailEmailAsync(string newEmailAddress, string token); Task SendChangeEmailEmailAsync(string newEmailAddress, string token);
Task SendNoMasterPasswordHintEmailAsync(string email); Task SendNoMasterPasswordHintEmailAsync(string email);
Task SendMasterPasswordHintEmailAsync(string email, string hint); Task SendMasterPasswordHintEmailAsync(string email, string hint);
Task SendOrganizationInviteEmailAsync(string organizationName, string email, string token); Task SendOrganizationInviteEmailAsync(string organizationName, OrganizationUser orgUser, string token);
} }
} }

View File

@ -26,7 +26,7 @@ namespace Bit.Core.Services
return Task.FromResult(0); 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); return Task.FromResult(0);
} }

View File

@ -150,7 +150,7 @@ namespace Bit.Core.Services
var nowMillis = CoreHelpers.ToEpocMilliseconds(DateTime.UtcNow); var nowMillis = CoreHelpers.ToEpocMilliseconds(DateTime.UtcNow);
var token = _dataProtector.Protect( var token = _dataProtector.Protect(
$"OrganizationUserInvite {orgUser.Id} {orgUser.Email} {nowMillis}"); $"OrganizationUserInvite {orgUser.Id} {orgUser.Email} {nowMillis}");
await _mailService.SendOrganizationInviteEmailAsync("Organization Name", orgUser.Email, token); await _mailService.SendOrganizationInviteEmailAsync("Organization Name", orgUser, token);
} }
public async Task<OrganizationUser> AcceptUserAsync(Guid organizationUserId, User user, string token) public async Task<OrganizationUser> AcceptUserAsync(Guid organizationUserId, User user, string token)
@ -189,7 +189,7 @@ namespace Bit.Core.Services
} }
orgUser.Status = Enums.OrganizationUserStatusType.Accepted; orgUser.Status = Enums.OrganizationUserStatusType.Accepted;
orgUser.UserId = orgUser.Id; orgUser.UserId = user.Id;
orgUser.Email = null; orgUser.Email = null;
await _organizationUserRepository.ReplaceAsync(orgUser); await _organizationUserRepository.ReplaceAsync(orgUser);

View File

@ -88,13 +88,15 @@ namespace Bit.Core.Services
await _client.SendEmailAsync(message); 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); var message = CreateDefaultMessage(OrganizationInviteTemplateId);
message.Subject = $"Join {organizationName}"; message.Subject = $"Join {organizationName}";
message.AddTo(new EmailAddress(email)); message.AddTo(new EmailAddress(orgUser.Email));
message.AddSubstitution("{{organizationName}}", organizationName); message.AddSubstitution("{{organizationName}}", organizationName);
message.AddSubstitution("{{organizationId}}", orgUser.OrganizationId.ToString());
message.AddSubstitution("{{organizationUserId}}", orgUser.Id.ToString());
message.AddSubstitution("{{token}}", token); message.AddSubstitution("{{token}}", token);
message.AddCategories(new List<string> { AdministrativeCategoryName, "Organization Invite" }); message.AddCategories(new List<string> { AdministrativeCategoryName, "Organization Invite" });