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

put back in the request for now.

This commit is contained in:
jrmccannon 2025-03-26 14:39:55 -05:00
parent 2f7c0ff1bf
commit d22cbb27e1
No known key found for this signature in database
GPG Key ID: CF03F3DB01CE96A6
3 changed files with 18 additions and 18 deletions

View File

@ -32,7 +32,8 @@ public class ScimUserRequestModel : BaseScimUserModel
public InviteOrganizationUsersRequest ToRequest(
ScimProviderType scimProvider,
InviteOrganization inviteOrganization,
DateTimeOffset performedAt)
DateTimeOffset performedAt,
bool hasSecretsManagerStandalone)
{
var email = EmailForInvite(scimProvider);
@ -47,7 +48,7 @@ public class ScimUserRequestModel : BaseScimUserModel
new Core.AdminConsole.OrganizationFeatures.OrganizationUsers.InviteUsers.Models.OrganizationUserInvite(
email: email,
externalId: ExternalIdForInvite(),
accessSecretsManager: false // TODO do something about this
accessSecretsManager: hasSecretsManagerStandalone
)
],
inviteOrganization: inviteOrganization,

View File

@ -63,10 +63,24 @@ public class PostUserCommand(
return null;
}
var hasSecretsManagerStandalone = await paymentService.HasSecretsManagerStandalone(organization);
var request = model.ToRequest(
scimProvider: scimProvider,
inviteOrganization: new InviteOrganization(organization, plan),
performedAt: timeProvider.GetUtcNow());
performedAt: timeProvider.GetUtcNow(),
hasSecretsManagerStandalone);
var orgUsers =
await organizationUserRepository.GetManyDetailsByOrganizationAsync(
request.InviteOrganization.OrganizationId);
if (orgUsers.Any(existingUser =>
request.Invites.First().Email.Equals(existingUser.Email, StringComparison.OrdinalIgnoreCase) ||
request.Invites.First().ExternalId.Equals(existingUser.ExternalId, StringComparison.OrdinalIgnoreCase)))
{
throw new ConflictException("User already exists.");
}
var result = await inviteOrganizationUsersCommand.InviteScimOrganizationUserAsync(request);

View File

@ -1,6 +1,5 @@
using Bit.Core.AdminConsole.Entities;
using Bit.Core.AdminConsole.Interfaces;
using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.InviteUsers.Errors;
using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.InviteUsers.Models;
using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.InviteUsers.Validation;
using Bit.Core.AdminConsole.Shared.Validation;
@ -44,20 +43,6 @@ public class InviteOrganizationUsersCommand(IEventService eventService,
public async Task<CommandResult<ScimInviteOrganizationUsersResponse>> InviteScimOrganizationUserAsync(InviteOrganizationUsersRequest request)
{
var hasSecretsManagerStandalone = await paymentService.HasSecretsManagerStandalone(request.InviteOrganization);
// Maybe move this all back up
var orgUsers = await organizationUserRepository.GetManyDetailsByOrganizationAsync(request.InviteOrganization.OrganizationId);
if (orgUsers.Any(existingUser =>
request.Invites.First().Email.Equals(existingUser.Email, StringComparison.InvariantCultureIgnoreCase) ||
request.Invites.First().ExternalId.Equals(existingUser.ExternalId, StringComparison.InvariantCultureIgnoreCase)))
{
return new Failure<ScimInviteOrganizationUsersResponse>(
new UserAlreadyExistsError(new ScimInviteOrganizationUsersResponse(request)));
}
// end of move
var result = await InviteOrganizationUsersAsync(request);
switch (result)