Skip to content

Commit

Permalink
Update CustomAuthorizationAttribute.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
Valentin Stoev authored Feb 17, 2020
1 parent e27a535 commit 2827aa3
Showing 1 changed file with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,13 @@ public CustomAuthorizationAttribute(params string[] allowedRoles)

public Task OnAuthorizationAsync(AuthorizationFilterContext context)
{
var userIsAuthenticated = context.HttpContext
.User
.Identity
.IsAuthenticated;
var userIsAuthenticated = context.HttpContext.User.Identity.IsAuthenticated;

if (userIsAuthenticated)
{
for (int i = 0; i < allowedRoles.Length; i++)
{
var isInRole = context.HttpContext
.User
.IsInRole(allowedRoles[i]);
var isInRole = context.HttpContext.User.IsInRole(allowedRoles[i]);

if (isInRole)
{
Expand Down

0 comments on commit 2827aa3

Please sign in to comment.