Skip to content

Commit

Permalink
fixed issue troygoode#19
Browse files Browse the repository at this point in the history
  • Loading branch information
troygoode committed Sep 24, 2011
1 parent 1637768 commit d6f22ef
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/MvcMembership/AuthorizeUnlessOnlyUserAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected override bool AuthorizeCore(HttpContextBase httpContext)

//allow anyone access if there are less than two users, otherwise
// - use normal logic (and cache this finding in a static variable)
if (!_hasAtLeastTwoUsers && _userService.TotalUsers > 1)
if (_hasAtLeastTwoUsers || _userService.TotalUsers > 1)
_hasAtLeastTwoUsers = true;
else
return true;
Expand All @@ -51,7 +51,11 @@ protected override bool AuthorizeCore(HttpContextBase httpContext)
return false;

//added the check for whether the role service is enabled or not. if it isn't, don't validate on that
return !_rolesService.Enabled || !_rolesSplit.Any() || _rolesSplit.Any(user.IsInRole);
if (!_rolesService.Enabled || !_rolesSplit.Any())
return true;

//is this user in one of the necessary roles?
return _rolesSplit.Any(user.IsInRole);
}

private static string[] SplitString(string original)
Expand Down

0 comments on commit d6f22ef

Please sign in to comment.