39 lines
749 B
C#
39 lines
749 B
C#
using System;
|
|
using zero.Core.Extensions;
|
|
|
|
namespace zero.Core.Api
|
|
{
|
|
public class ApiScope
|
|
{
|
|
public string AppId { get; set; }
|
|
|
|
public bool IncludeShared { get; set; }
|
|
|
|
//public bool OnlyShared { get; set; }
|
|
|
|
public bool IsShared { get; set; }
|
|
|
|
public bool IsAppAware => !IsShared && !AppId.IsNullOrEmpty();
|
|
|
|
public bool IsAllowed(string appId)
|
|
{
|
|
if (!IsAppAware)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
if (appId.IsNullOrWhiteSpace())
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (IncludeShared && appId.Equals(Constants.Database.SharedAppId, StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
return true;
|
|
}
|
|
|
|
return appId.Equals(AppId, StringComparison.OrdinalIgnoreCase);
|
|
}
|
|
}
|
|
}
|