mirror of
https://github.com/bitwarden/server
synced 2025-12-23 03:33:35 +00:00
WIP: scaffolding for families for enterprise sponsorship flow
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Core.Models.Table
|
||||
@@ -7,10 +8,15 @@ namespace Bit.Core.Models.Table
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid InstallationId { get; set; }
|
||||
[Required]
|
||||
public Guid SponsoringOrganizationId { get; set; }
|
||||
[Required]
|
||||
public Guid SponsoringOrganizationUserId { get; set; }
|
||||
public Guid SponsoringUserId { get; set; }
|
||||
[MaxLength(256)]
|
||||
public string OfferedToEmail { get; set; }
|
||||
public Guid? SponsoredOrganizationId { get; set; }
|
||||
[Required]
|
||||
public bool CloudSponsor { get; set; }
|
||||
public DateTime? LastSyncDate { get; set; }
|
||||
public byte TimesRenewedWithoutValidation { get; set; }
|
||||
|
||||
@@ -10,5 +10,6 @@ namespace Bit.Core.Repositories
|
||||
{
|
||||
Task<OrganizationSponsorship> GetBySponsoringOrganizationUserIdAsync(Guid sponsoringOrganizationUserId);
|
||||
Task<OrganizationSponsorship> GetBySponsoredOrganizationIdAsync(Guid sponsoredOrganizationId);
|
||||
Task<OrganizationSponsorship> GetByOfferedToEmailAsync(string email);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
@@ -26,7 +25,10 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
{
|
||||
var results = await connection.QueryAsync<OrganizationSponsorship>(
|
||||
"[dbo].[OrganizationSponsorship_ReadBySponsoringOrganizationUserId]",
|
||||
new { SponsoringOrganizationUserId = sponsoringOrganizationUserId },
|
||||
new
|
||||
{
|
||||
SponsoringOrganizationUserId = sponsoringOrganizationUserId
|
||||
},
|
||||
commandType: CommandType.StoredProcedure);
|
||||
|
||||
return results.SingleOrDefault();
|
||||
@@ -45,5 +47,21 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
return results.SingleOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<OrganizationSponsorship> GetByOfferedToEmailAsync(string offeredToEmail)
|
||||
{
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<OrganizationSponsorship>(
|
||||
"[dbo].[OrganizationSponsorship_ReadByOfferedToEmail]",
|
||||
new
|
||||
{
|
||||
OfferedToEmail = offeredToEmail
|
||||
},
|
||||
commandType: CommandType.StoredProcedure);
|
||||
|
||||
return results.SingleOrDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
using System.Threading.Tasks;
|
||||
using Bit.Core.Models.Table;
|
||||
|
||||
namespace Bit.Core.Services
|
||||
{
|
||||
public interface IOrganizationSponsorshipService
|
||||
{
|
||||
|
||||
Task OfferSponsorshipAsync(Organization sponsoringOrg, OrganizationUser sponsoringOrgUser, string sponsoredEmail);
|
||||
Task SetUpSponsorshipAsync(OrganizationSponsorship sponsorship, Organization sponsoredOrganization);
|
||||
Task RemoveSponsorshipAsync(OrganizationSponsorship sponsorship);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Bit.Core.Models.Table;
|
||||
using Bit.Core.Repositories;
|
||||
|
||||
namespace Bit.Core.Services
|
||||
@@ -10,5 +13,24 @@ namespace Bit.Core.Services
|
||||
{
|
||||
_organizationSponsorshipRepository = organizationSponsorshipRepository;
|
||||
}
|
||||
|
||||
public async Task OfferSponsorshipAsync(Organization sponsoringOrg, OrganizationUser sponsoringOrgUser, string sponsoredEmail)
|
||||
{
|
||||
// TODO: send sponsorship email, update sponsorship with offered email
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task SetUpSponsorshipAsync(OrganizationSponsorship sponsorship, Organization sponsoredOrganization)
|
||||
{
|
||||
// TODO: set up sponsorship
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task RemoveSponsorshipAsync(OrganizationSponsorship sponsorship)
|
||||
{
|
||||
// TODO: remove sponsorship
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user