Skip to content

Commit

Permalink
Added Inviting users to organization API.
Browse files Browse the repository at this point in the history
  • Loading branch information
jezzsantos committed Apr 2, 2024
1 parent 747d9f1 commit bdcff40
Show file tree
Hide file tree
Showing 57 changed files with 1,346 additions and 209 deletions.
8 changes: 4 additions & 4 deletions docs/design-principles/0150-all-use-cases.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ These are the main use cases of this product that are exposed via "public" APIs

#### Machines

1. Register a new machine
1. Register a new machine (anonymously or by authenticated user)

#### Password Credentials

1. Authenticate the current user (with a password)
2. Register a new person (with a password, and optional invitation)
2. Register a new person (with a password and with optional invitation)
3. Confirm registration of a person (from email)

#### Single-Sign On
Expand All @@ -98,9 +98,9 @@ TBD

### Organizations

1. Create a new organization for the current user
1. Create a new (shared) organization for the current user
2. Inspect a specific organization
3. Invite another user to the organization (by email, or an existing user by email or by ID)
3. Invite another guest or person to an organization (guest by email, or an existing person by email or by ID)

### Subscriptions

Expand Down
9 changes: 9 additions & 0 deletions src/Application.Resources.Shared/EndUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ public class Membership : IIdentifiableResource
public List<string> Roles { get; set; } = new();

public required string Id { get; set; }

public required string UserId { get; set; }
}

public class MembershipWithUserProfile : Membership
{
public EndUserStatus Status { get; set; }

public required UserProfile Profile { get; set; }
}

public class Invitation
Expand Down
23 changes: 23 additions & 0 deletions src/Application.Resources.Shared/Organization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,27 @@ public enum OrganizationOwnership
{
Shared = 0,
Personal = 1
}

public class OrganizationMember : IIdentifiableResource
{
public UserProfileClassification Classification { get; set; }

public string? EmailAddress { get; set; }

public List<string> Features { get; set; } = new();

public bool IsDefault { get; set; }

public bool IsOwner { get; set; }

public bool IsRegistered { get; set; }

public required PersonName Name { get; set; }

public List<string> Roles { get; set; } = new();

public required string UserId { get; set; }

public required string Id { get; set; }
}
4 changes: 2 additions & 2 deletions src/Application.Resources.Shared/UserProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ public class UserProfile : IIdentifiableResource

public string? Timezone { get; set; }

public UserProfileType Type { get; set; }
public UserProfileClassification Classification { get; set; }

public required string UserId { get; set; }

public required string Id { get; set; }
}

public enum UserProfileType
public enum UserProfileClassification
{
Person = 0,
Machine = 1
Expand Down
15 changes: 10 additions & 5 deletions src/Application.Services.Shared/IEndUsersService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@ Task<Result<Optional<EndUser>, Error>> FindPersonByEmailPrivateAsync(ICallerCont
Task<Result<EndUserWithMemberships, Error>> GetMembershipsPrivateAsync(ICallerContext caller, string id,
CancellationToken cancellationToken);

Task<Result<Membership, Error>> InviteMemberToOrganizationPrivateAsync(ICallerContext caller, string organizationId,
string? userId, string? emailAddress, CancellationToken cancellationToken);

Task<Result<SearchResults<MembershipWithUserProfile>, Error>> ListMembershipsForOrganizationAsync(
ICallerContext caller,
string organizationId, SearchOptions searchOptions, GetOptions getOptions, CancellationToken cancellationToken);

Task<Result<RegisteredEndUser, Error>> RegisterMachinePrivateAsync(ICallerContext caller, string name,
string? timezone,
string? countryCode, CancellationToken cancellationToken);
string? timezone, string? countryCode, CancellationToken cancellationToken);

Task<Result<RegisteredEndUser, Error>> RegisterPersonPrivateAsync(ICallerContext caller, string? invitationToken,
string emailAddress,
string firstName, string? lastName, string? timezone, string? countryCode, bool termsAndConditionsAccepted,
CancellationToken cancellationToken);
string emailAddress, string firstName, string? lastName, string? timezone, string? countryCode,
bool termsAndConditionsAccepted, CancellationToken cancellationToken);
}
3 changes: 3 additions & 0 deletions src/Application.Services.Shared/IUserProfilesService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ Task<Result<UserProfile, Error>> CreatePersonProfilePrivateAsync(ICallerContext
Task<Result<Optional<UserProfile>, Error>> FindPersonByEmailAddressPrivateAsync(ICallerContext caller,
string emailAddress, CancellationToken cancellationToken);

Task<Result<List<UserProfile>, Error>> GetAllProfilesPrivateAsync(ICallerContext caller, List<string> ids,
GetOptions options, CancellationToken cancellationToken);

Task<Result<UserProfile, Error>> GetProfilePrivateAsync(ICallerContext caller, string userId,
CancellationToken cancellationToken);
}
16 changes: 8 additions & 8 deletions src/EndUsersApplication.UnitTests/EndUsersApplicationSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public async Task WhenRegisterPersonAsyncAndWasInvitedAsGuest_ThenCompletesRegis
.ReturnsAsync(new UserProfile
{
Id = "aprofileid",
Type = UserProfileType.Person,
Classification = UserProfileClassification.Person,
UserId = "apersonid",
DisplayName = "afirstname",
Name = new PersonName
Expand Down Expand Up @@ -206,7 +206,7 @@ await invitee.InviteGuestAsync(tokensService.Object, "aninviterid".ToId(),
.ReturnsAsync(new UserProfile
{
Id = "aprofileid",
Type = UserProfileType.Person,
Classification = UserProfileClassification.Person,
UserId = "apersonid",
DisplayName = "afirstname",
Name = new PersonName
Expand Down Expand Up @@ -276,7 +276,7 @@ public async Task WhenRegisterPersonAsyncAndAcceptingAnUnknownInvitation_ThenReg
.ReturnsAsync(new UserProfile
{
Id = "aprofileid",
Type = UserProfileType.Person,
Classification = UserProfileClassification.Person,
UserId = "apersonid",
DisplayName = "afirstname",
Name = new PersonName
Expand Down Expand Up @@ -346,7 +346,7 @@ public async Task
.ReturnsAsync(new UserProfile
{
Id = "anotherprofileid",
Type = UserProfileType.Person,
Classification = UserProfileClassification.Person,
UserId = "anotherpersonid",
DisplayName = "afirstname",
Name = new PersonName
Expand Down Expand Up @@ -394,7 +394,7 @@ public async Task WhenRegisterPersonAsyncAndAlreadyRegistered_ThenSendsCourtesyE
.ReturnsAsync(new UserProfile
{
Id = "aprofileid",
Type = UserProfileType.Person,
Classification = UserProfileClassification.Person,
UserId = "auserid",
DisplayName = "afirstname",
Name = new PersonName
Expand Down Expand Up @@ -468,7 +468,7 @@ public async Task WhenRegisterPersonAsyncAndNeverRegisteredNorInvitedAsGuest_The
.ReturnsAsync(new UserProfile
{
Id = "aprofileid",
Type = UserProfileType.Person,
Classification = UserProfileClassification.Person,
UserId = "apersonid",
DisplayName = "afirstname",
Name = new PersonName
Expand Down Expand Up @@ -523,7 +523,7 @@ public async Task WhenRegisterMachineAsyncByAnonymousUser_ThenRegistersWithNoFea
.ReturnsAsync(new UserProfile
{
Id = "aprofileid",
Type = UserProfileType.Machine,
Classification = UserProfileClassification.Machine,
UserId = "amachineid",
DisplayName = "amachinename",
Name = new PersonName
Expand Down Expand Up @@ -582,7 +582,7 @@ public async Task WhenRegisterMachineAsyncByAuthenticatedUser_ThenRegistersWithB
.ReturnsAsync(new UserProfile
{
Id = "aprofileid",
Type = UserProfileType.Machine,
Classification = UserProfileClassification.Machine,
UserId = "amachineid",
DisplayName = "amachinename",
Name = new PersonName
Expand Down
Loading

0 comments on commit bdcff40

Please sign in to comment.