Skip to content

Commit

Permalink
Add a way to Remove User from a Role (Issue OrchardCMS#14632) (build …
Browse files Browse the repository at this point in the history
…error)
  • Loading branch information
elaurentin committed Nov 13, 2023
1 parent 28f0b15 commit 344a6a7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,20 @@ public IEnumerable<string> Roles

public override IEnumerable<Outcome> GetPossibleOutcomes(WorkflowExecutionContext workflowContext, ActivityContext activityContext)
=> Outcomes(S["Done"], S["Failed"]);


public override async Task<ActivityExecutionResult> ExecuteAsync(WorkflowExecutionContext workflowContext, ActivityContext activityContext)
{
var outputKeyName = await _expressionEvaluator.EvaluateAsync(OutputKeyName, workflowContext, null);

if (!string.IsNullOrEmpty(propKeyName))
if (!string.IsNullOrEmpty(outputKeyName))
{
var usersInRole = new Dictionary<string, User>();

foreach (var role in Roles)
{
foreach(var u in await _userManager.GetUsersInRoleAsync(role))
{
if(u is not User user)
if (u is not User user)
{
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public IEnumerable<string> Roles

public override IEnumerable<Outcome> GetPossibleOutcomes(WorkflowExecutionContext workflowContext, ActivityContext activityContext)
=> Outcomes(S["Done"], S["Failed"]);

public override async Task<ActivityExecutionResult> ExecuteAsync(WorkflowExecutionContext workflowContext, ActivityContext activityContext)
{
var userName = await _expressionEvaluator.EvaluateAsync(UserName, workflowContext, null);
Expand All @@ -62,7 +62,7 @@ public override async Task<ActivityExecutionResult> ExecuteAsync(WorkflowExecuti
await _userManager.RemoveFromRoleAsync(user, role);
}
}

return Outcomes("Done");
}

Expand Down

0 comments on commit 344a6a7

Please sign in to comment.