25 lines
707 B
C#
25 lines
707 B
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using zero.Core.Entities;
|
|
using zero.Core.Identity;
|
|
|
|
namespace zero.Core.Extensions
|
|
{
|
|
public static class BackofficeUserExtensions
|
|
{
|
|
public static string[] GetAllowedAppIds(this IBackofficeUser user)
|
|
{
|
|
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();
|
|
}
|
|
}
|
|
}
|