mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-29 11:54:27 +01:00
Builds on #1368 This PR adds a new endpoint: Get current user.. It only returns the current user's id and email for now( let's extend later) It also adds a new permission: `ProfileManagement` which is needed for this endpoint (and for update endpoints later)
30 lines
1012 B
C#
30 lines
1012 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace BTCPayServer.Client
|
|
{
|
|
public static class Permissions
|
|
{
|
|
public const string ServerManagement = nameof(ServerManagement);
|
|
public const string StoreManagement = nameof(StoreManagement);
|
|
public const string ProfileManagement = nameof(ProfileManagement);
|
|
|
|
public static string[] GetAllPermissionKeys()
|
|
{
|
|
return new[]
|
|
{
|
|
ServerManagement,
|
|
StoreManagement,
|
|
ProfileManagement
|
|
};
|
|
}
|
|
public static string GetStorePermission(string storeId) => $"{nameof(StoreManagement)}:{storeId}";
|
|
|
|
public static IEnumerable<string> ExtractStorePermissionsIds(IEnumerable<string> permissions) => permissions
|
|
.Where(s => s.StartsWith($"{nameof(StoreManagement)}:", StringComparison.InvariantCulture))
|
|
.Select(s => s.Split(":")[1]);
|
|
}
|
|
}
|