Refactor permissions of GreenField

This commit is contained in:
nicolas.dorier
2020-03-19 19:11:15 +09:00
parent eac33d494a
commit 29a807696b
31 changed files with 581 additions and 404 deletions

View File

@@ -10,6 +10,7 @@ using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Routing;
using Microsoft.AspNetCore.Authentication;
using Microsoft.Extensions.Primitives;
using BTCPayServer.Client;
namespace BTCPayServer.Security
{
@@ -35,7 +36,7 @@ namespace BTCPayServer.Security
var isAdmin = context.User.IsInRole(Roles.ServerAdmin);
switch (requirement.Policy)
{
case Policies.CanModifyServerSettings.Key:
case Permission.CanModifyServerSettings:
if (isAdmin)
context.Succeed(requirement);
return;
@@ -56,11 +57,11 @@ namespace BTCPayServer.Security
bool success = false;
switch (requirement.Policy)
{
case Policies.CanModifyStoreSettings.Key:
case Permission.CanModifyStoreSettings:
if (store.Role == StoreRoles.Owner || isAdmin)
success = true;
break;
case Policies.CanCreateInvoice.Key:
case Permission.CanCreateInvoice:
if (store.Role == StoreRoles.Owner ||
store.Role == StoreRoles.Guest ||
isAdmin ||