2020-11-16 14:48:23 +01:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using zero.Core.Entities;
|
|
|
|
|
using zero.Core.Identity;
|
|
|
|
|
|
|
|
|
|
namespace zero.Core.Extensions
|
|
|
|
|
{
|
|
|
|
|
public static class BackofficeUserExtensions
|
|
|
|
|
{
|
2021-05-04 17:23:52 +02:00
|
|
|
public static string[] GetAllowedAppIds(this BackofficeUser user)
|
2020-11-16 14:48:23 +01:00
|
|
|
{
|
|
|
|
|
if (user == null)
|
|
|
|
|
{
|
|
|
|
|
return new string[0] { };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IEnumerable<Permission> permissions = user.Claims
|
|
|
|
|
.Where(claim => claim.Type == Constants.Auth.Claims.Permission && claim.Value.StartsWith(Permissions.Applications))
|
|
|
|
|
.Select(x => Permission.FromClaim(x.ToClaim(), Permissions.Applications));
|
|
|
|
|
|
|
|
|
|
return permissions.Where(x => x.IsTrue).Select(x => x.NormalizedKey).ToArray();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|