mirror of
https://github.com/bitwarden/server.git
synced 2025-04-05 05:00:19 -05:00
Made public method private. added some comments.
This commit is contained in:
parent
d867b47705
commit
e1eb458036
@ -1,13 +1,16 @@
|
|||||||
using Bit.Core.AdminConsole.Entities;
|
using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.InviteUsers.Models;
|
||||||
using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.InviteUsers.Models;
|
|
||||||
using Bit.Core.Entities;
|
|
||||||
using Bit.Core.Models.Mail;
|
|
||||||
|
|
||||||
namespace Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.InviteUsers;
|
namespace Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.InviteUsers;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This is for sending the invite to an organization user.
|
||||||
|
/// </summary>
|
||||||
public interface ISendOrganizationInvitesCommand
|
public interface ISendOrganizationInvitesCommand
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This sends emails out to organization users for a given organization.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request"><see cref="SendInvitesRequest"/></param>
|
||||||
|
/// <returns></returns>
|
||||||
Task SendInvitesAsync(SendInvitesRequest request);
|
Task SendInvitesAsync(SendInvitesRequest request);
|
||||||
|
|
||||||
Task<OrganizationInvitesInfo> BuildOrganizationInvitesInfoAsync(IEnumerable<OrganizationUser> orgUsers, Organization organization, bool initOrganization = false);
|
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,33 @@
|
|||||||
using Bit.Core.AdminConsole.Entities;
|
#nullable enable
|
||||||
|
|
||||||
|
using Bit.Core.AdminConsole.Entities;
|
||||||
using Bit.Core.Entities;
|
using Bit.Core.Entities;
|
||||||
|
|
||||||
namespace Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.InviteUsers.Models;
|
namespace Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.InviteUsers.Models;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a request to send invitations to a group of organization users.
|
||||||
|
/// </summary>
|
||||||
public class SendInvitesRequest
|
public class SendInvitesRequest
|
||||||
{
|
{
|
||||||
public SendInvitesRequest() { }
|
|
||||||
|
|
||||||
public SendInvitesRequest(IEnumerable<OrganizationUser> users, Organization organization) =>
|
public SendInvitesRequest(IEnumerable<OrganizationUser> users, Organization organization) =>
|
||||||
(Users, Organization) = (users.ToArray(), organization);
|
(Users, Organization) = (users.ToArray(), organization);
|
||||||
|
|
||||||
|
public SendInvitesRequest(IEnumerable<OrganizationUser> users, Organization organization, bool initOrganization) =>
|
||||||
|
(Users, Organization, InitOrganization) = (users.ToArray(), organization, initOrganization);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Organization Users to send emails to.
|
||||||
|
/// </summary>
|
||||||
public OrganizationUser[] Users { get; set; } = [];
|
public OrganizationUser[] Users { get; set; } = [];
|
||||||
public Organization Organization { get; set; } = null!;
|
|
||||||
|
/// <summary>
|
||||||
|
/// The organization to invite the users to.
|
||||||
|
/// </summary>
|
||||||
|
public Organization Organization { get; init; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This is for when the organization is being created and this is the owners initial invite
|
||||||
|
/// </summary>
|
||||||
|
public bool InitOrganization { get; init; }
|
||||||
}
|
}
|
||||||
|
@ -23,12 +23,12 @@ public class SendOrganizationInvitesCommand(
|
|||||||
{
|
{
|
||||||
public async Task SendInvitesAsync(SendInvitesRequest request)
|
public async Task SendInvitesAsync(SendInvitesRequest request)
|
||||||
{
|
{
|
||||||
var orgInvitesInfo = await BuildOrganizationInvitesInfoAsync(request.Users, request.Organization);
|
var orgInvitesInfo = await BuildOrganizationInvitesInfoAsync(request.Users, request.Organization, request.InitOrganization);
|
||||||
|
|
||||||
await mailService.SendOrganizationInviteEmailsAsync(orgInvitesInfo);
|
await mailService.SendOrganizationInviteEmailsAsync(orgInvitesInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<OrganizationInvitesInfo> BuildOrganizationInvitesInfoAsync(IEnumerable<OrganizationUser> orgUsers,
|
private async Task<OrganizationInvitesInfo> BuildOrganizationInvitesInfoAsync(IEnumerable<OrganizationUser> orgUsers,
|
||||||
Organization organization, bool initOrganization = false)
|
Organization organization, bool initOrganization = false)
|
||||||
{
|
{
|
||||||
// Materialize the sequence into a list to avoid multiple enumeration warnings
|
// Materialize the sequence into a list to avoid multiple enumeration warnings
|
||||||
|
@ -27,7 +27,6 @@ using Bit.Core.Exceptions;
|
|||||||
using Bit.Core.Models.Business;
|
using Bit.Core.Models.Business;
|
||||||
using Bit.Core.Models.Data;
|
using Bit.Core.Models.Data;
|
||||||
using Bit.Core.Models.Data.Organizations.OrganizationUsers;
|
using Bit.Core.Models.Data.Organizations.OrganizationUsers;
|
||||||
using Bit.Core.Models.Mail;
|
|
||||||
using Bit.Core.OrganizationFeatures.OrganizationSubscriptions.Interface;
|
using Bit.Core.OrganizationFeatures.OrganizationSubscriptions.Interface;
|
||||||
using Bit.Core.Platform.Push;
|
using Bit.Core.Platform.Push;
|
||||||
using Bit.Core.Repositories;
|
using Bit.Core.Repositories;
|
||||||
@ -1055,20 +1054,11 @@ public class OrganizationService : IOrganizationService
|
|||||||
private async Task SendInvitesAsync(IEnumerable<OrganizationUser> orgUsers, Organization organization) =>
|
private async Task SendInvitesAsync(IEnumerable<OrganizationUser> orgUsers, Organization organization) =>
|
||||||
await _sendOrganizationInvitesCommand.SendInvitesAsync(new SendInvitesRequest(orgUsers, organization));
|
await _sendOrganizationInvitesCommand.SendInvitesAsync(new SendInvitesRequest(orgUsers, organization));
|
||||||
|
|
||||||
private async Task SendInviteAsync(OrganizationUser orgUser, Organization organization, bool initOrganization)
|
private async Task SendInviteAsync(OrganizationUser orgUser, Organization organization, bool initOrganization) =>
|
||||||
{
|
await _sendOrganizationInvitesCommand.SendInvitesAsync(new SendInvitesRequest(
|
||||||
// convert single org user into array of 1 org user
|
users: [orgUser],
|
||||||
var orgUsers = new[] { orgUser };
|
organization: organization,
|
||||||
|
initOrganization: initOrganization));
|
||||||
var orgInvitesInfo = await BuildOrganizationInvitesInfoAsync(orgUsers, organization, initOrganization);
|
|
||||||
|
|
||||||
await _mailService.SendOrganizationInviteEmailsAsync(orgInvitesInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task<OrganizationInvitesInfo> BuildOrganizationInvitesInfoAsync(
|
|
||||||
IEnumerable<OrganizationUser> orgUsers, Organization organization, bool initOrganization = false) =>
|
|
||||||
await _sendOrganizationInvitesCommand.BuildOrganizationInvitesInfoAsync(orgUsers, organization,
|
|
||||||
initOrganization);
|
|
||||||
|
|
||||||
public async Task<OrganizationUser> ConfirmUserAsync(Guid organizationId, Guid organizationUserId, string key,
|
public async Task<OrganizationUser> ConfirmUserAsync(Guid organizationId, Guid organizationUserId, string key,
|
||||||
Guid confirmingUserId)
|
Guid confirmingUserId)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user