Initial commit
This commit is contained in:
11
Oqtane.Client/Services/IModuleDefinitionService.cs
Normal file
11
Oqtane.Client/Services/IModuleDefinitionService.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using Oqtane.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Oqtane.Services
|
||||
{
|
||||
public interface IModuleDefinitionService
|
||||
{
|
||||
Task<List<ModuleDefinition>> GetModuleDefinitionsAsync();
|
||||
}
|
||||
}
|
15
Oqtane.Client/Services/IModuleService.cs
Normal file
15
Oqtane.Client/Services/IModuleService.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using Oqtane.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Oqtane.Services
|
||||
{
|
||||
public interface IModuleService
|
||||
{
|
||||
Task<List<Module>> GetModulesAsync(int PageId);
|
||||
Task<List<Module>> GetModulesAsync(int SiteId, string ModuleDefinitionName);
|
||||
Task AddModuleAsync(Module module);
|
||||
Task UpdateModuleAsync(Module module);
|
||||
Task DeleteModuleAsync(int ModuleId);
|
||||
}
|
||||
}
|
14
Oqtane.Client/Services/IPageModuleService.cs
Normal file
14
Oqtane.Client/Services/IPageModuleService.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using Oqtane.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Oqtane.Services
|
||||
{
|
||||
public interface IPageModuleService
|
||||
{
|
||||
Task<List<PageModule>> GetPageModulesAsync();
|
||||
Task AddPageModuleAsync(PageModule pagemodule);
|
||||
Task UpdatePageModuleAsync(PageModule pagemodule);
|
||||
Task DeletePageModuleAsync(int PageModuleId);
|
||||
}
|
||||
}
|
14
Oqtane.Client/Services/IPageService.cs
Normal file
14
Oqtane.Client/Services/IPageService.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using Oqtane.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Oqtane.Services
|
||||
{
|
||||
public interface IPageService
|
||||
{
|
||||
Task<List<Page>> GetPagesAsync(int SiteId);
|
||||
Task AddPageAsync(Page page);
|
||||
Task UpdatePageAsync(Page page);
|
||||
Task DeletePageAsync(int PageId);
|
||||
}
|
||||
}
|
19
Oqtane.Client/Services/ISiteService.cs
Normal file
19
Oqtane.Client/Services/ISiteService.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using Oqtane.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Oqtane.Services
|
||||
{
|
||||
public interface ISiteService
|
||||
{
|
||||
Task<List<Site>> GetSitesAsync();
|
||||
|
||||
Task<Site> GetSiteAsync(int SiteId);
|
||||
|
||||
Task AddSiteAsync(Site site);
|
||||
|
||||
Task UpdateSiteAsync(Site site);
|
||||
|
||||
Task DeleteSiteAsync(int SiteId);
|
||||
}
|
||||
}
|
11
Oqtane.Client/Services/ISkinService.cs
Normal file
11
Oqtane.Client/Services/ISkinService.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using Oqtane.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Oqtane.Services
|
||||
{
|
||||
public interface ISkinService
|
||||
{
|
||||
Task<List<Skin>> GetSkinsAsync();
|
||||
}
|
||||
}
|
10
Oqtane.Client/Services/ITenantService.cs
Normal file
10
Oqtane.Client/Services/ITenantService.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using Oqtane.Models;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Oqtane.Services
|
||||
{
|
||||
public interface ITenantService
|
||||
{
|
||||
Task<Tenant> GetTenantAsync();
|
||||
}
|
||||
}
|
21
Oqtane.Client/Services/IUserService.cs
Normal file
21
Oqtane.Client/Services/IUserService.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using Oqtane.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Oqtane.Services
|
||||
{
|
||||
public interface IUserService
|
||||
{
|
||||
Task<List<User>> GetUsersAsync();
|
||||
|
||||
Task<User> GetUserAsync(int UserId);
|
||||
|
||||
Task AddUserAsync(User user);
|
||||
|
||||
Task UpdateUserAsync(User user);
|
||||
|
||||
Task DeleteUserAsync(int UserId);
|
||||
|
||||
bool IsAuthorized(User user, string accesscontrollist);
|
||||
}
|
||||
}
|
60
Oqtane.Client/Services/ModuleDefinitionService.cs
Normal file
60
Oqtane.Client/Services/ModuleDefinitionService.cs
Normal file
@ -0,0 +1,60 @@
|
||||
using Oqtane.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Oqtane.Services
|
||||
{
|
||||
public class ModuleDefinitionService : ServiceBase, IModuleDefinitionService
|
||||
{
|
||||
private readonly HttpClient http;
|
||||
private readonly string apiurl;
|
||||
|
||||
private List<ModuleDefinition> moduledefinitions;
|
||||
|
||||
public ModuleDefinitionService(HttpClient http, IUriHelper urihelper)
|
||||
{
|
||||
this.http = http;
|
||||
apiurl = CreateApiUrl(urihelper.GetAbsoluteUri(), "ModuleDefinition");
|
||||
}
|
||||
|
||||
public async Task<List<ModuleDefinition>> GetModuleDefinitionsAsync()
|
||||
{
|
||||
if (moduledefinitions == null)
|
||||
{
|
||||
moduledefinitions = await http.GetJsonAsync<List<ModuleDefinition>>(apiurl);
|
||||
|
||||
// get list of loaded assemblies
|
||||
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
|
||||
|
||||
foreach (ModuleDefinition moduledefinition in moduledefinitions)
|
||||
{
|
||||
if (moduledefinition.Dependencies != "")
|
||||
{
|
||||
foreach (string dependency in moduledefinition.Dependencies.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
string assemblyname = dependency.Replace(".dll", "");
|
||||
if (assemblies.Where(item => item.FullName.StartsWith(assemblyname + ",")).FirstOrDefault() == null)
|
||||
{
|
||||
// download assembly from server and load
|
||||
var bytes = await http.GetByteArrayAsync("_framework/_bin/" + assemblyname + ".dll");
|
||||
Assembly.Load(bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (assemblies.Where(item => item.FullName.StartsWith(moduledefinition.AssemblyName + ",")).FirstOrDefault() == null)
|
||||
{
|
||||
// download assembly from server and load
|
||||
var bytes = await http.GetByteArrayAsync("_framework/_bin/" + moduledefinition.AssemblyName + ".dll");
|
||||
Assembly.Load(bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
return moduledefinitions.OrderBy(item => item.Name).ToList();
|
||||
}
|
||||
}
|
||||
}
|
51
Oqtane.Client/Services/ModuleService.cs
Normal file
51
Oqtane.Client/Services/ModuleService.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using Oqtane.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace Oqtane.Services
|
||||
{
|
||||
public class ModuleService : ServiceBase, IModuleService
|
||||
{
|
||||
private readonly HttpClient http;
|
||||
private readonly string apiurl;
|
||||
|
||||
public ModuleService(HttpClient http, IUriHelper urihelper)
|
||||
{
|
||||
this.http = http;
|
||||
apiurl = CreateApiUrl(urihelper.GetAbsoluteUri(), "Module");
|
||||
}
|
||||
|
||||
public async Task<List<Module>> GetModulesAsync(int PageId)
|
||||
{
|
||||
List<Module> modules = await http.GetJsonAsync<List<Module>>(apiurl + "?pageid=" + PageId.ToString());
|
||||
modules = modules
|
||||
.OrderBy(item => item.Order)
|
||||
.ToList();
|
||||
return modules;
|
||||
}
|
||||
|
||||
public async Task<List<Module>> GetModulesAsync(int SiteId, string ModuleDefinitionName)
|
||||
{
|
||||
List<Module> modules = await http.GetJsonAsync<List<Module>>(apiurl + "?siteid=" + SiteId.ToString() + "&moduledefinitionname=" + ModuleDefinitionName);
|
||||
return modules.ToList();
|
||||
}
|
||||
|
||||
public async Task AddModuleAsync(Module module)
|
||||
{
|
||||
await http.PostJsonAsync(apiurl, module);
|
||||
}
|
||||
|
||||
public async Task UpdateModuleAsync(Module module)
|
||||
{
|
||||
await http.PutJsonAsync(apiurl + "/" + module.ModuleId.ToString(), module);
|
||||
}
|
||||
|
||||
public async Task DeleteModuleAsync(int ModuleId)
|
||||
{
|
||||
await http.DeleteAsync(apiurl + "/" + ModuleId.ToString());
|
||||
}
|
||||
}
|
||||
}
|
41
Oqtane.Client/Services/PageModuleService.cs
Normal file
41
Oqtane.Client/Services/PageModuleService.cs
Normal file
@ -0,0 +1,41 @@
|
||||
using Oqtane.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace Oqtane.Services
|
||||
{
|
||||
public class PageModuleService : ServiceBase, IPageModuleService
|
||||
{
|
||||
private readonly HttpClient http;
|
||||
private readonly string apiurl;
|
||||
|
||||
public PageModuleService(HttpClient http, IUriHelper urihelper)
|
||||
{
|
||||
this.http = http;
|
||||
apiurl = CreateApiUrl(urihelper.GetAbsoluteUri(), "PageModule");
|
||||
}
|
||||
|
||||
public async Task<List<PageModule>> GetPageModulesAsync()
|
||||
{
|
||||
return await http.GetJsonAsync<List<PageModule>>(apiurl);
|
||||
}
|
||||
|
||||
public async Task AddPageModuleAsync(PageModule pagemodule)
|
||||
{
|
||||
await http.PostJsonAsync(apiurl, pagemodule);
|
||||
}
|
||||
|
||||
public async Task UpdatePageModuleAsync(PageModule pagemodule)
|
||||
{
|
||||
await http.PutJsonAsync(apiurl + "/" + pagemodule.PageModuleId.ToString(), pagemodule);
|
||||
}
|
||||
|
||||
public async Task DeletePageModuleAsync(int PageModuleId)
|
||||
{
|
||||
await http.DeleteAsync(apiurl + "/" + PageModuleId.ToString());
|
||||
}
|
||||
}
|
||||
}
|
41
Oqtane.Client/Services/PageService.cs
Normal file
41
Oqtane.Client/Services/PageService.cs
Normal file
@ -0,0 +1,41 @@
|
||||
using Oqtane.Models;
|
||||
using System.Threading.Tasks;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Oqtane.Services
|
||||
{
|
||||
public class PageService : ServiceBase, IPageService
|
||||
{
|
||||
private readonly HttpClient http;
|
||||
private readonly string apiurl;
|
||||
|
||||
public PageService(HttpClient http, IUriHelper urihelper)
|
||||
{
|
||||
this.http = http;
|
||||
apiurl = CreateApiUrl(urihelper.GetAbsoluteUri(), "Page");
|
||||
}
|
||||
|
||||
public async Task<List<Page>> GetPagesAsync(int SiteId)
|
||||
{
|
||||
List<Page> pages = await http.GetJsonAsync<List<Page>>(apiurl + "?siteid=" + SiteId.ToString());
|
||||
return pages.OrderBy(item => item.Order).ToList();
|
||||
}
|
||||
|
||||
public async Task AddPageAsync(Page page)
|
||||
{
|
||||
await http.PostJsonAsync(apiurl, page);
|
||||
}
|
||||
|
||||
public async Task UpdatePageAsync(Page page)
|
||||
{
|
||||
await http.PutJsonAsync(apiurl + "/" + page.PageId.ToString(), page);
|
||||
}
|
||||
public async Task DeletePageAsync(int PageId)
|
||||
{
|
||||
await http.DeleteAsync(apiurl + "/" + PageId.ToString());
|
||||
}
|
||||
}
|
||||
}
|
25
Oqtane.Client/Services/ServiceBase.cs
Normal file
25
Oqtane.Client/Services/ServiceBase.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using Oqtane.Shared;
|
||||
|
||||
namespace Oqtane.Services
|
||||
{
|
||||
public class ServiceBase
|
||||
{
|
||||
public string CreateApiUrl(string absoluteUri, string serviceName)
|
||||
{
|
||||
Uri uri = new Uri(absoluteUri);
|
||||
string apiurl = uri.Scheme + "://" + uri.Authority + "/";
|
||||
string alias = Utilities.GetAlias(absoluteUri);
|
||||
if (alias != "")
|
||||
{
|
||||
apiurl += alias;
|
||||
}
|
||||
else
|
||||
{
|
||||
apiurl += "~/";
|
||||
}
|
||||
apiurl += "api/" + serviceName;
|
||||
return apiurl;
|
||||
}
|
||||
}
|
||||
}
|
56
Oqtane.Client/Services/SiteService.cs
Normal file
56
Oqtane.Client/Services/SiteService.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using Oqtane.Models;
|
||||
using System.Threading.Tasks;
|
||||
using System.Net.Http;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Oqtane.Services
|
||||
{
|
||||
public class SiteService : ServiceBase, ISiteService
|
||||
{
|
||||
private readonly HttpClient http;
|
||||
private readonly string apiurl;
|
||||
|
||||
public SiteService(HttpClient http, IUriHelper urihelper)
|
||||
{
|
||||
this.http = http;
|
||||
apiurl = CreateApiUrl(urihelper.GetAbsoluteUri(), "Site");
|
||||
}
|
||||
|
||||
public async Task<List<Site>> GetSitesAsync()
|
||||
{
|
||||
List<Site> sites = await http.GetJsonAsync<List<Site>>(apiurl);
|
||||
return sites.OrderBy(item => item.Name).ToList();
|
||||
}
|
||||
|
||||
public async Task<Site> GetSiteAsync(int SiteId)
|
||||
{
|
||||
List<Site> sites = await http.GetJsonAsync<List<Site>>(apiurl);
|
||||
Site site;
|
||||
if (sites.Count == 1)
|
||||
{
|
||||
site = sites.FirstOrDefault();
|
||||
}
|
||||
else
|
||||
{
|
||||
site = sites.Where(item => item.SiteId == SiteId).FirstOrDefault();
|
||||
}
|
||||
return site;
|
||||
}
|
||||
|
||||
public async Task AddSiteAsync(Site site)
|
||||
{
|
||||
await http.PostJsonAsync(apiurl, site);
|
||||
}
|
||||
|
||||
public async Task UpdateSiteAsync(Site site)
|
||||
{
|
||||
await http.PutJsonAsync(apiurl + "/" + site.SiteId.ToString(), site);
|
||||
}
|
||||
public async Task DeleteSiteAsync(int SiteId)
|
||||
{
|
||||
await http.DeleteAsync(apiurl + "/" + SiteId.ToString());
|
||||
}
|
||||
}
|
||||
}
|
60
Oqtane.Client/Services/SkinService.cs
Normal file
60
Oqtane.Client/Services/SkinService.cs
Normal file
@ -0,0 +1,60 @@
|
||||
using Oqtane.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System.Reflection;
|
||||
using System;
|
||||
|
||||
namespace Oqtane.Services
|
||||
{
|
||||
public class SkinService : ServiceBase, ISkinService
|
||||
{
|
||||
private readonly HttpClient http;
|
||||
private readonly string apiurl;
|
||||
|
||||
private List<Skin> skins;
|
||||
|
||||
public SkinService(HttpClient http, IUriHelper urihelper)
|
||||
{
|
||||
this.http = http;
|
||||
apiurl = CreateApiUrl(urihelper.GetAbsoluteUri(), "Skin");
|
||||
}
|
||||
|
||||
public async Task<List<Skin>> GetSkinsAsync()
|
||||
{
|
||||
if (skins == null)
|
||||
{
|
||||
skins = await http.GetJsonAsync<List<Skin>>(apiurl);
|
||||
|
||||
// get list of loaded assemblies
|
||||
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
|
||||
|
||||
foreach (Skin skin in skins)
|
||||
{
|
||||
if (skin.Dependencies != "")
|
||||
{
|
||||
foreach (string dependency in skin.Dependencies.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
string assemblyname = dependency.Replace(".dll", "");
|
||||
if (assemblies.Where(item => item.FullName.StartsWith(assemblyname + ",")).FirstOrDefault() == null)
|
||||
{
|
||||
// download assembly from server and load
|
||||
var bytes = await http.GetByteArrayAsync("_framework/_bin/" + assemblyname + ".dll");
|
||||
Assembly.Load(bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (assemblies.Where(item => item.FullName.StartsWith(skin.AssemblyName + ",")).FirstOrDefault() == null)
|
||||
{
|
||||
// download assembly from server and load
|
||||
var bytes = await http.GetByteArrayAsync("_framework/_bin/" + skin.AssemblyName + ".dll");
|
||||
Assembly.Load(bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
return skins.OrderBy(item => item.Name).ToList();
|
||||
}
|
||||
}
|
||||
}
|
24
Oqtane.Client/Services/TenantService.cs
Normal file
24
Oqtane.Client/Services/TenantService.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using Oqtane.Models;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace Oqtane.Services
|
||||
{
|
||||
public class TenantService : ServiceBase, ITenantService
|
||||
{
|
||||
private readonly HttpClient http;
|
||||
private readonly string apiurl;
|
||||
|
||||
public TenantService(HttpClient http, IUriHelper urihelper)
|
||||
{
|
||||
this.http = http;
|
||||
apiurl = CreateApiUrl(urihelper.GetAbsoluteUri(), "Tenant");
|
||||
}
|
||||
|
||||
public async Task<Tenant> GetTenantAsync()
|
||||
{
|
||||
return await http.GetJsonAsync<Tenant>(apiurl);
|
||||
}
|
||||
}
|
||||
}
|
122
Oqtane.Client/Services/UserService.cs
Normal file
122
Oqtane.Client/Services/UserService.cs
Normal file
@ -0,0 +1,122 @@
|
||||
using Oqtane.Shared;
|
||||
using Oqtane.Models;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Oqtane.Services
|
||||
{
|
||||
public class UserService : ServiceBase, IUserService
|
||||
{
|
||||
private readonly HttpClient http;
|
||||
private readonly string apiurl;
|
||||
|
||||
public UserService(HttpClient http, IUriHelper urihelper)
|
||||
{
|
||||
this.http = http;
|
||||
apiurl = CreateApiUrl(urihelper.GetAbsoluteUri(), "User");
|
||||
}
|
||||
|
||||
public async Task<List<User>> GetUsersAsync()
|
||||
{
|
||||
List<User> users = await http.GetJsonAsync<List<User>>(apiurl);
|
||||
return users.OrderBy(item => item.DisplayName).ToList();
|
||||
}
|
||||
|
||||
public async Task<User> GetUserAsync(int UserId)
|
||||
{
|
||||
List<User> users = await http.GetJsonAsync<List<User>>(apiurl);
|
||||
return users.Where(item => item.UserId == UserId).FirstOrDefault();
|
||||
}
|
||||
|
||||
public async Task AddUserAsync(User user)
|
||||
{
|
||||
await http.PostJsonAsync(apiurl, user);
|
||||
}
|
||||
|
||||
public async Task UpdateUserAsync(User user)
|
||||
{
|
||||
await http.PutJsonAsync(apiurl + "/" + user.UserId.ToString(), user);
|
||||
}
|
||||
public async Task DeleteUserAsync(int UserId)
|
||||
{
|
||||
await http.DeleteAsync(apiurl + "/" + UserId.ToString());
|
||||
}
|
||||
|
||||
// ACLs are stored in the format "!rolename1;![userid1];rolename2;rolename3;[userid2];[userid3]" where "!" designates Deny permissions
|
||||
public bool IsAuthorized(User user, string accesscontrollist)
|
||||
{
|
||||
bool isAllowed = false;
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
//super user always has full access
|
||||
isAllowed = user.IsSuperUser;
|
||||
}
|
||||
|
||||
if (!isAllowed)
|
||||
{
|
||||
if (accesscontrollist != null)
|
||||
{
|
||||
foreach (string permission in accesscontrollist.Split(new[] { ';' }))
|
||||
{
|
||||
bool? allowed = VerifyPermission(user, permission);
|
||||
if (allowed.HasValue)
|
||||
{
|
||||
isAllowed = allowed.Value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return isAllowed;
|
||||
}
|
||||
|
||||
private bool? VerifyPermission(User user, string permission)
|
||||
{
|
||||
bool? allowed = null;
|
||||
//permissions strings are encoded with deny permissions at the beginning and grant permissions at the end for optimal performance
|
||||
if (!String.IsNullOrEmpty(permission))
|
||||
{
|
||||
// deny permission
|
||||
if (permission.StartsWith("!"))
|
||||
{
|
||||
string denyRole = permission.Replace("!", "");
|
||||
if (denyRole == Constants.AllUsersRole || IsAllowed(user, denyRole))
|
||||
{
|
||||
allowed = false;
|
||||
}
|
||||
}
|
||||
else // grant permission
|
||||
{
|
||||
if (permission == Constants.AllUsersRole || IsAllowed(user, permission))
|
||||
{
|
||||
allowed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return allowed;
|
||||
}
|
||||
|
||||
private bool IsAllowed(User user, string permission)
|
||||
{
|
||||
if (user != null)
|
||||
{
|
||||
if ("[" + user.UserId + "]" == permission)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
var roles = user.Roles;
|
||||
if (roles != null)
|
||||
{
|
||||
return roles.IndexOf(";" + permission + ";") != -1;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user