using System.Linq; using Tanshu.Accounts.Entities; namespace Tanshu.Accounts.Contracts { public static class Session { private static User _currentUser; public static bool IsAuthenticated { get; private set; } public static User User { get { return _currentUser; } set { if (value != null) { _currentUser = value; IsAuthenticated = true; } else { _currentUser = null; IsAuthenticated = false; } } } public static bool IsAllowed(string role) { if (_currentUser == null) return false; return _currentUser.Permissions.Any(x => x.Name == role); } } }