Skip to content

Commit

Permalink
More fixes for ChilliCream#624, now on the .net classic part of the code
Browse files Browse the repository at this point in the history
  • Loading branch information
eduleite committed Mar 11, 2019
1 parent 9092124 commit f58512f
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/Server/AspNetCore.Authorization/AuthorizeDirective.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,21 @@ public AuthorizeDirective(
ArgumentNode rolesArgument = node.Arguments
.FirstOrDefault(t => t.Name.Value == "roles");

Roles = (rolesArgument != null
&& rolesArgument.Value is ListValueNode lv)
? lv.Items.OfType<StringValueNode>()
.Select(t => t.Value?.Trim())
.Where(s => !string.IsNullOrEmpty(s))
.ToArray()
: Array.Empty<string>();
Roles = Array.Empty<string>();
if (rolesArgument != null)
{
if (rolesArgument.Value is ListValueNode lv)
{
Roles = lv.Items.OfType<StringValueNode>()
.Select(t => t.Value?.Trim())
.Where(s => !string.IsNullOrEmpty(s))
.ToArray();
}
else if (rolesArgument.Value is StringValueNode svn)
{
Roles = new[] { svn.Value };
}
}
}
}

Expand Down

0 comments on commit f58512f

Please sign in to comment.