fix(workspace-invite): inconsistence in roles names
This commit is contained in:
@@ -2,10 +2,10 @@
|
||||
|
||||
public static class KnownRoles
|
||||
{
|
||||
public const string Administrator = nameof(Administrator);
|
||||
public const string Manager = nameof(Manager);
|
||||
public const string Client = nameof(Client);
|
||||
public const string Provider = nameof(Provider);
|
||||
public const string WorkspaceMember = nameof(WorkspaceMember);
|
||||
public const string Developer = nameof(Developer);
|
||||
public const string Administrator = "administrator";
|
||||
public const string Manager = "manager";
|
||||
public const string Client = "client";
|
||||
public const string Provider = "provider";
|
||||
public const string WorkspaceMember = "workspace-member";
|
||||
public const string Developer = "developer";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Socialize.Api.Modules.Workspaces.Data;
|
||||
|
||||
public static class WorkspaceInviteStatuses
|
||||
{
|
||||
public const string Pending = "Pending";
|
||||
}
|
||||
@@ -24,7 +24,7 @@ public class CreateWorkspaceInviteRequestValidator
|
||||
public CreateWorkspaceInviteRequestValidator()
|
||||
{
|
||||
RuleFor(x => x.Email).NotEmpty().MaximumLength(256).EmailAddress();
|
||||
RuleFor(x => x.Role).NotEmpty().Must(role => AllowedRoles.Contains(role));
|
||||
RuleFor(x => x.Role).NotEmpty().Must(role => AllowedRoles.Contains(role)).WithMessage("A valid role should be specified");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ public class CreateWorkspaceInviteHandler(
|
||||
bool duplicateInvite = await dbContext.WorkspaceInvites.AnyAsync(
|
||||
invite => invite.WorkspaceId == workspaceId &&
|
||||
invite.Email == normalizedEmail &&
|
||||
invite.Status == "Pending",
|
||||
invite.Status == WorkspaceInviteStatuses.Pending,
|
||||
ct);
|
||||
|
||||
if (duplicateInvite)
|
||||
@@ -81,7 +81,7 @@ public class CreateWorkspaceInviteHandler(
|
||||
WorkspaceId = workspaceId,
|
||||
Email = normalizedEmail,
|
||||
Role = normalizedRole,
|
||||
Status = "Pending",
|
||||
Status = WorkspaceInviteStatuses.Pending,
|
||||
InvitedByUserId = User.GetUserId(),
|
||||
CreatedAt = DateTimeOffset.UtcNow,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user