1
0
mirror of https://github.com/bitwarden/server synced 2025-12-24 12:13:17 +00:00

Use userId to find org users

This commit is contained in:
Matt Gibson
2021-11-09 10:40:31 -05:00
committed by Justin Baur
parent 1516b9dd8e
commit 8480379e32
5 changed files with 11 additions and 41 deletions

View File

@@ -51,14 +51,10 @@ namespace Bit.Api.Controllers
throw new BadRequestException("Specified Organization cannot sponsor other organizations.");
}
var sponsoringOrgUser = await _organizationUserRepository.GetByIdAsync(model.OrganizationUserId);
var sponsoringOrgUser = await _organizationUserRepository.GetByOrganizationAsync(sponsoringOrgIdGuid, _currentContext.UserId ?? default);
if (sponsoringOrgUser == null || sponsoringOrgUser.Status != OrganizationUserStatusType.Confirmed)
{
throw new BadRequestException("Only confirm users can sponsor other organizations.");
}
if (sponsoringOrgUser.UserId != _currentContext.UserId)
{
throw new BadRequestException("Can only create organization sponsorships for yourself.");
throw new BadRequestException("Only confirmed users can sponsor other organizations.");
}
var existingOrgSponsorship = await _organizationSponsorshipRepository.GetBySponsoringOrganizationUserIdAsync(sponsoringOrgUser.Id);

View File

@@ -10,9 +10,6 @@ namespace Bit.Core.Models.Api.Request
[Required]
public PlanSponsorshipType PlanSponsorshipType { get; set; }
[Required]
public Guid OrganizationUserId { get; set; }
[Required]
[StringLength(256)]
[StrictEmailAddress]

View File

@@ -88,7 +88,7 @@ namespace Bit.Core.Services
sponsorship = await _organizationSponsorshipRepository.CreateAsync(sponsorship);
// TODO: send email to sponsoredEmail w/ redemption token link
var _ = RedemptionToken(sponsorship.Id, sponsorshipType);
// var _ = RedemptionToken(sponsorship.Id, sponsorshipType);
}
catch
{