Factored out Contants.*** Role into RoleNames.***
Renamed 'AllUsers' to 'Everyone'
This commit is contained in:
@ -32,7 +32,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// GET: api/<controller>
|
||||
[HttpGet]
|
||||
[Authorize(Roles = Constants.AdminRole)]
|
||||
[Authorize(Roles = RoleNames.Admin)]
|
||||
public IEnumerable<Alias> Get()
|
||||
{
|
||||
return _aliases.GetAliases();
|
||||
@ -40,7 +40,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// GET api/<controller>/5
|
||||
[HttpGet("{id}")]
|
||||
[Authorize(Roles = Constants.AdminRole)]
|
||||
[Authorize(Roles = RoleNames.Admin)]
|
||||
public Alias Get(int id)
|
||||
{
|
||||
return _aliases.GetAlias(id);
|
||||
@ -86,7 +86,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// POST api/<controller>
|
||||
[HttpPost]
|
||||
[Authorize(Roles = Constants.AdminRole)]
|
||||
[Authorize(Roles = RoleNames.Admin)]
|
||||
public Alias Post([FromBody] Alias alias)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
@ -99,7 +99,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Roles = Constants.AdminRole)]
|
||||
[Authorize(Roles = RoleNames.Admin)]
|
||||
public Alias Put(int id, [FromBody] Alias alias)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
@ -112,7 +112,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// DELETE api/<controller>/5
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Roles = Constants.AdminRole)]
|
||||
[Authorize(Roles = RoleNames.Admin)]
|
||||
public void Delete(int id)
|
||||
{
|
||||
_aliases.DeleteAlias(id);
|
||||
|
@ -58,7 +58,7 @@ namespace Oqtane.Controllers
|
||||
}
|
||||
else
|
||||
{
|
||||
if (User.IsInRole(Constants.HostRole))
|
||||
if (User.IsInRole(RoleNames.Host))
|
||||
{
|
||||
folder = GetFolderPath(folder);
|
||||
if (Directory.Exists(folder))
|
||||
@ -132,7 +132,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
[Authorize(Roles = RoleNames.Registered)]
|
||||
public Models.File Put(int id, [FromBody] Models.File file)
|
||||
{
|
||||
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, EntityNames.Folder, file.FolderId, PermissionNames.Edit))
|
||||
@ -164,7 +164,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// DELETE api/<controller>/5
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
[Authorize(Roles = RoleNames.Registered)]
|
||||
public void Delete(int id)
|
||||
{
|
||||
Models.File file = _files.GetFile(id);
|
||||
@ -282,7 +282,7 @@ namespace Oqtane.Controllers
|
||||
}
|
||||
else
|
||||
{
|
||||
if (User.IsInRole(Constants.HostRole))
|
||||
if (User.IsInRole(RoleNames.Host))
|
||||
{
|
||||
folderPath = GetFolderPath(folder);
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// POST api/<controller>
|
||||
[HttpPost]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
[Authorize(Roles = RoleNames.Registered)]
|
||||
public Folder Post([FromBody] Folder folder)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
@ -106,7 +106,7 @@ namespace Oqtane.Controllers
|
||||
else
|
||||
{
|
||||
permissions = new List<Permission> {
|
||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true),
|
||||
new Permission(PermissionNames.Edit, RoleNames.Admin, true),
|
||||
}.EncodePermissions();
|
||||
}
|
||||
if (_userPermissions.IsAuthorized(User, PermissionNames.Edit, permissions))
|
||||
@ -141,7 +141,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
[Authorize(Roles = RoleNames.Registered)]
|
||||
public Folder Put(int id, [FromBody] Folder folder)
|
||||
{
|
||||
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, EntityNames.Folder, folder.FolderId, PermissionNames.Edit))
|
||||
@ -182,7 +182,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// PUT api/<controller>/?siteid=x&folderid=y&parentid=z
|
||||
[HttpPut]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
[Authorize(Roles = RoleNames.Registered)]
|
||||
public void Put(int siteid, int folderid, int? parentid)
|
||||
{
|
||||
if (_userPermissions.IsAuthorized(User, EntityNames.Folder, folderid, PermissionNames.Edit))
|
||||
@ -209,7 +209,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// DELETE api/<controller>/5
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
[Authorize(Roles = RoleNames.Registered)]
|
||||
public void Delete(int id)
|
||||
{
|
||||
if (_userPermissions.IsAuthorized(User, EntityNames.Folder, id, PermissionNames.Edit))
|
||||
|
@ -36,7 +36,7 @@ namespace Oqtane.Controllers
|
||||
{
|
||||
var installation = new Installation {Success = false, Message = ""};
|
||||
|
||||
if (ModelState.IsValid && (User.IsInRole(Constants.HostRole) || string.IsNullOrEmpty(_config.GetConnectionString(SettingKeys.ConnectionStringKey))))
|
||||
if (ModelState.IsValid && (User.IsInRole(RoleNames.Host) || string.IsNullOrEmpty(_config.GetConnectionString(SettingKeys.ConnectionStringKey))))
|
||||
{
|
||||
installation = _databaseManager.Install(config);
|
||||
}
|
||||
@ -57,7 +57,7 @@ namespace Oqtane.Controllers
|
||||
}
|
||||
|
||||
[HttpGet("upgrade")]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
[Authorize(Roles = RoleNames.Host)]
|
||||
public Installation Upgrade()
|
||||
{
|
||||
var installation = new Installation {Success = true, Message = ""};
|
||||
|
@ -28,7 +28,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// GET: api/<controller>
|
||||
[HttpGet]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
[Authorize(Roles = RoleNames.Host)]
|
||||
public IEnumerable<Job> Get()
|
||||
{
|
||||
return _jobs.GetJobs();
|
||||
@ -36,7 +36,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// GET api/<controller>/5
|
||||
[HttpGet("{id}")]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
[Authorize(Roles = RoleNames.Host)]
|
||||
public Job Get(int id)
|
||||
{
|
||||
return _jobs.GetJob(id);
|
||||
@ -44,7 +44,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// POST api/<controller>
|
||||
[HttpPost]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
[Authorize(Roles = RoleNames.Host)]
|
||||
public Job Post([FromBody] Job job)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
@ -57,7 +57,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
[Authorize(Roles = RoleNames.Host)]
|
||||
public Job Put(int id, [FromBody] Job job)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
@ -70,7 +70,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// DELETE api/<controller>/5
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
[Authorize(Roles = RoleNames.Host)]
|
||||
public void Delete(int id)
|
||||
{
|
||||
_jobs.DeleteJob(id);
|
||||
@ -79,7 +79,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// GET api/<controller>/start
|
||||
[HttpGet("start/{id}")]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
[Authorize(Roles = RoleNames.Host)]
|
||||
public void Start(int id)
|
||||
{
|
||||
Job job = _jobs.GetJob(id);
|
||||
@ -93,7 +93,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// GET api/<controller>/stop
|
||||
[HttpGet("stop/{id}")]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
[Authorize(Roles = RoleNames.Host)]
|
||||
public void Stop(int id)
|
||||
{
|
||||
Job job = _jobs.GetJob(id);
|
||||
|
@ -23,7 +23,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// GET: api/<controller>
|
||||
[HttpGet]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
[Authorize(Roles = RoleNames.Host)]
|
||||
public IEnumerable<JobLog> Get()
|
||||
{
|
||||
return _jobLogs.GetJobLogs();
|
||||
@ -31,7 +31,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// GET api/<controller>/5
|
||||
[HttpGet("{id}")]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
[Authorize(Roles = RoleNames.Host)]
|
||||
public JobLog Get(int id)
|
||||
{
|
||||
return _jobLogs.GetJobLog(id);
|
||||
@ -39,7 +39,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// POST api/<controller>
|
||||
[HttpPost]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
[Authorize(Roles = RoleNames.Host)]
|
||||
public JobLog Post([FromBody] JobLog jobLog)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
@ -52,7 +52,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
[Authorize(Roles = RoleNames.Host)]
|
||||
public JobLog Put(int id, [FromBody] JobLog jobLog)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
@ -65,7 +65,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// DELETE api/<controller>/5
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
[Authorize(Roles = RoleNames.Host)]
|
||||
public void Delete(int id)
|
||||
{
|
||||
_jobLogs.DeleteJobLog(id);
|
||||
|
@ -23,7 +23,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// GET: api/<controller>?siteid=x&level=y&function=z&rows=50
|
||||
[HttpGet]
|
||||
[Authorize(Roles = Constants.AdminRole)]
|
||||
[Authorize(Roles = RoleNames.Admin)]
|
||||
public IEnumerable<Log> Get(string siteid, string level, string function, string rows)
|
||||
{
|
||||
return _logs.GetLogs(int.Parse(siteid), level, function, int.Parse(rows));
|
||||
@ -31,7 +31,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// GET api/<controller>/5
|
||||
[HttpGet("{id}")]
|
||||
[Authorize(Roles = Constants.AdminRole)]
|
||||
[Authorize(Roles = RoleNames.Admin)]
|
||||
public Log Get(int id)
|
||||
{
|
||||
return _logs.GetLog(id);
|
||||
|
@ -89,7 +89,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// POST api/<controller>
|
||||
[HttpPost]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
[Authorize(Roles = RoleNames.Registered)]
|
||||
public Module Post([FromBody] Module module)
|
||||
{
|
||||
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, EntityNames.Page, module.PageId, PermissionNames.Edit))
|
||||
@ -108,7 +108,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
[Authorize(Roles = RoleNames.Registered)]
|
||||
public Module Put(int id, [FromBody] Module module)
|
||||
{
|
||||
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, EntityNames.Module, module.ModuleId, PermissionNames.Edit))
|
||||
@ -140,7 +140,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// DELETE api/<controller>/5
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
[Authorize(Roles = RoleNames.Registered)]
|
||||
public void Delete(int id)
|
||||
{
|
||||
if (_userPermissions.IsAuthorized(User, EntityNames.Module, id, PermissionNames.Edit))
|
||||
@ -157,7 +157,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// GET api/<controller>/export?moduleid=x
|
||||
[HttpGet("export")]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
[Authorize(Roles = RoleNames.Registered)]
|
||||
public string Export(int moduleid)
|
||||
{
|
||||
string content = "";
|
||||
@ -175,7 +175,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// POST api/<controller>/import?moduleid=x
|
||||
[HttpPost("import")]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
[Authorize(Roles = RoleNames.Registered)]
|
||||
public bool Import(int moduleid, [FromBody] string content)
|
||||
{
|
||||
bool success = false;
|
||||
|
@ -81,7 +81,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Roles = Constants.AdminRole)]
|
||||
[Authorize(Roles = RoleNames.Admin)]
|
||||
public void Put(int id, [FromBody] ModuleDefinition moduleDefinition)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
@ -92,7 +92,7 @@ namespace Oqtane.Controllers
|
||||
}
|
||||
|
||||
[HttpGet("install")]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
[Authorize(Roles = RoleNames.Host)]
|
||||
public void InstallModules()
|
||||
{
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Modules Installed");
|
||||
@ -101,7 +101,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// DELETE api/<controller>/5?siteid=x
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
[Authorize(Roles = RoleNames.Host)]
|
||||
public void Delete(int id, int siteid)
|
||||
{
|
||||
ModuleDefinition moduledefinition = _moduleDefinitions.GetModuleDefinition(id, siteid);
|
||||
@ -168,7 +168,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// POST api/<controller>?moduleid=x
|
||||
[HttpPost]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
[Authorize(Roles = RoleNames.Host)]
|
||||
public void Post([FromBody] ModuleDefinition moduleDefinition, string moduleid)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
|
@ -26,7 +26,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// GET: api/<controller>?siteid=x&type=y&userid=z
|
||||
[HttpGet]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
[Authorize(Roles = RoleNames.Registered)]
|
||||
public IEnumerable<Notification> Get(string siteid, string direction, string userid)
|
||||
{
|
||||
IEnumerable<Notification> notifications = null;
|
||||
@ -46,7 +46,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// GET api/<controller>/5
|
||||
[HttpGet("{id}")]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
[Authorize(Roles = RoleNames.Registered)]
|
||||
public Notification Get(int id)
|
||||
{
|
||||
Notification notification = _notifications.GetNotification(id);
|
||||
@ -59,7 +59,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// POST api/<controller>
|
||||
[HttpPost]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
[Authorize(Roles = RoleNames.Registered)]
|
||||
public Notification Post([FromBody] Notification notification)
|
||||
{
|
||||
if (IsAuthorized(notification.FromUserId))
|
||||
@ -72,7 +72,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
[Authorize(Roles = RoleNames.Registered)]
|
||||
public Notification Put(int id, [FromBody] Notification notification)
|
||||
{
|
||||
if (IsAuthorized(notification.FromUserId))
|
||||
@ -85,7 +85,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// DELETE api/<controller>/5
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
[Authorize(Roles = RoleNames.Registered)]
|
||||
public void Delete(int id)
|
||||
{
|
||||
Notification notification = _notifications.GetNotification(id);
|
||||
|
@ -27,7 +27,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// GET: api/<controller>?tag=x
|
||||
[HttpGet]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
[Authorize(Roles = RoleNames.Host)]
|
||||
public async Task<IEnumerable<Package>> Get(string tag)
|
||||
{
|
||||
List<Package> packages = new List<Package>();
|
||||
@ -56,7 +56,7 @@ namespace Oqtane.Controllers
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
[Authorize(Roles = RoleNames.Host)]
|
||||
public async Task Post(string packageid, string version, string folder)
|
||||
{
|
||||
using (var httpClient = new HttpClient())
|
||||
|
@ -102,7 +102,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// POST api/<controller>
|
||||
[HttpPost]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
[Authorize(Roles = RoleNames.Registered)]
|
||||
public Page Post([FromBody] Page page)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
@ -115,7 +115,7 @@ namespace Oqtane.Controllers
|
||||
else
|
||||
{
|
||||
permissions = new List<Permission> {
|
||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
||||
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||
}.EncodePermissions();
|
||||
}
|
||||
|
||||
@ -147,7 +147,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// POST api/<controller>/5?userid=x
|
||||
[HttpPost("{id}")]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
[Authorize(Roles = RoleNames.Registered)]
|
||||
public Page Post(int id, string userid)
|
||||
{
|
||||
Page page = null;
|
||||
@ -213,7 +213,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
[Authorize(Roles = RoleNames.Registered)]
|
||||
public Page Put(int id, [FromBody] Page page)
|
||||
{
|
||||
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, EntityNames.Page, page.PageId, PermissionNames.Edit))
|
||||
@ -233,7 +233,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// PUT api/<controller>/?siteid=x&pageid=y&parentid=z
|
||||
[HttpPut]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
[Authorize(Roles = RoleNames.Registered)]
|
||||
public void Put(int siteid, int pageid, int? parentid)
|
||||
{
|
||||
if (_userPermissions.IsAuthorized(User, EntityNames.Page, pageid, PermissionNames.Edit))
|
||||
@ -261,7 +261,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// DELETE api/<controller>/5
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
[Authorize(Roles = RoleNames.Registered)]
|
||||
public void Delete(int id)
|
||||
{
|
||||
Page page = _pages.GetPage(id);
|
||||
|
@ -65,7 +65,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// POST api/<controller>
|
||||
[HttpPost]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
[Authorize(Roles = RoleNames.Registered)]
|
||||
public PageModule Post([FromBody] PageModule pageModule)
|
||||
{
|
||||
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, EntityNames.Page, pageModule.PageId, PermissionNames.Edit))
|
||||
@ -85,7 +85,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
[Authorize(Roles = RoleNames.Registered)]
|
||||
public PageModule Put(int id, [FromBody] PageModule pageModule)
|
||||
{
|
||||
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, EntityNames.Module, pageModule.ModuleId, PermissionNames.Edit))
|
||||
@ -105,7 +105,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// PUT api/<controller>/?pageid=x&pane=y
|
||||
[HttpPut]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
[Authorize(Roles = RoleNames.Registered)]
|
||||
public void Put(int pageid, string pane)
|
||||
{
|
||||
if (_userPermissions.IsAuthorized(User, EntityNames.Page, pageid, PermissionNames.Edit))
|
||||
@ -133,7 +133,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// DELETE api/<controller>/5
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
[Authorize(Roles = RoleNames.Registered)]
|
||||
public void Delete(int id)
|
||||
{
|
||||
PageModule pagemodule = _pageModules.GetPageModule(id);
|
||||
|
@ -37,7 +37,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// POST api/<controller>
|
||||
[HttpPost]
|
||||
[Authorize(Roles = Constants.AdminRole)]
|
||||
[Authorize(Roles = RoleNames.Admin)]
|
||||
public Profile Post([FromBody] Profile profile)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
@ -50,7 +50,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Roles = Constants.AdminRole)]
|
||||
[Authorize(Roles = RoleNames.Admin)]
|
||||
public Profile Put(int id, [FromBody] Profile profile)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
@ -63,7 +63,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// DELETE api/<controller>/5
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Roles = Constants.AdminRole)]
|
||||
[Authorize(Roles = RoleNames.Admin)]
|
||||
public void Delete(int id)
|
||||
{
|
||||
_profiles.DeleteProfile(id);
|
||||
|
@ -23,7 +23,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// GET: api/<controller>?siteid=x
|
||||
[HttpGet]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
[Authorize(Roles = RoleNames.Registered)]
|
||||
public IEnumerable<Role> Get(string siteid)
|
||||
{
|
||||
return _roles.GetRoles(int.Parse(siteid));
|
||||
@ -31,7 +31,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// GET api/<controller>/5
|
||||
[HttpGet("{id}")]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
[Authorize(Roles = RoleNames.Registered)]
|
||||
public Role Get(int id)
|
||||
{
|
||||
return _roles.GetRole(id);
|
||||
@ -39,7 +39,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// POST api/<controller>
|
||||
[HttpPost]
|
||||
[Authorize(Roles = Constants.AdminRole)]
|
||||
[Authorize(Roles = RoleNames.Admin)]
|
||||
public Role Post([FromBody] Role role)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
@ -52,7 +52,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Roles = Constants.AdminRole)]
|
||||
[Authorize(Roles = RoleNames.Admin)]
|
||||
public Role Put(int id, [FromBody] Role role)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
@ -65,7 +65,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// DELETE api/<controller>/5
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Roles = Constants.AdminRole)]
|
||||
[Authorize(Roles = RoleNames.Admin)]
|
||||
public void Delete(int id)
|
||||
{
|
||||
_roles.DeleteRole(id);
|
||||
|
@ -124,10 +124,10 @@ namespace Oqtane.Controllers
|
||||
switch (entityName)
|
||||
{
|
||||
case EntityNames.Tenant:
|
||||
authorized = User.IsInRole(Constants.HostRole);
|
||||
authorized = User.IsInRole(RoleNames.Host);
|
||||
break;
|
||||
case EntityNames.Site:
|
||||
authorized = User.IsInRole(Constants.AdminRole);
|
||||
authorized = User.IsInRole(RoleNames.Admin);
|
||||
break;
|
||||
case EntityNames.Page:
|
||||
case EntityNames.Module:
|
||||
@ -138,7 +138,7 @@ namespace Oqtane.Controllers
|
||||
authorized = true;
|
||||
if (permissionName == PermissionNames.Edit)
|
||||
{
|
||||
authorized = User.IsInRole(Constants.AdminRole) || (_userPermissions.GetUser(User).UserId == entityId);
|
||||
authorized = User.IsInRole(RoleNames.Admin) || (_userPermissions.GetUser(User).UserId == entityId);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// GET: api/<controller>
|
||||
[HttpGet]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
[Authorize(Roles = RoleNames.Host)]
|
||||
public IEnumerable<Site> Get()
|
||||
{
|
||||
return _sites.GetSites();
|
||||
@ -57,7 +57,7 @@ namespace Oqtane.Controllers
|
||||
}
|
||||
else
|
||||
{
|
||||
authorized = User.IsInRole(Constants.HostRole);
|
||||
authorized = User.IsInRole(RoleNames.Host);
|
||||
}
|
||||
if (authorized)
|
||||
{
|
||||
@ -70,7 +70,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Roles = Constants.AdminRole)]
|
||||
[Authorize(Roles = RoleNames.Admin)]
|
||||
public Site Put(int id, [FromBody] Site site)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
@ -84,7 +84,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// DELETE api/<controller>/5
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
[Authorize(Roles = RoleNames.Host)]
|
||||
public void Delete(int id)
|
||||
{
|
||||
_sites.DeleteSite(id);
|
||||
|
@ -19,7 +19,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// GET: api/<controller>
|
||||
[HttpGet]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
[Authorize(Roles = RoleNames.Host)]
|
||||
public IEnumerable<SiteTemplate> Get()
|
||||
{
|
||||
return _siteTemplates.GetSiteTemplates();
|
||||
|
@ -30,7 +30,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// POST: api/<controller>
|
||||
[HttpPost]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
[Authorize(Roles = RoleNames.Host)]
|
||||
public SqlQuery Post([FromBody] SqlQuery sqlquery)
|
||||
{
|
||||
var results = new List<Dictionary<string, string>>();
|
||||
|
@ -19,7 +19,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// GET: api/<controller>
|
||||
[HttpGet]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
[Authorize(Roles = RoleNames.Host)]
|
||||
public Dictionary<string, string> Get()
|
||||
{
|
||||
Dictionary<string, string> systeminfo = new Dictionary<string, string>();
|
||||
|
@ -23,7 +23,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// GET: api/<controller>
|
||||
[HttpGet]
|
||||
[Authorize(Roles = Constants.AdminRole)]
|
||||
[Authorize(Roles = RoleNames.Admin)]
|
||||
public IEnumerable<Tenant> Get()
|
||||
{
|
||||
return _tenants.GetTenants();
|
||||
@ -31,7 +31,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// GET api/<controller>/5
|
||||
[HttpGet("{id}")]
|
||||
[Authorize(Roles = Constants.AdminRole)]
|
||||
[Authorize(Roles = RoleNames.Admin)]
|
||||
public Tenant Get(int id)
|
||||
{
|
||||
return _tenants.GetTenant(id);
|
||||
@ -39,7 +39,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// POST api/<controller>
|
||||
[HttpPost]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
[Authorize(Roles = RoleNames.Host)]
|
||||
public Tenant Post([FromBody] Tenant tenant)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
@ -52,7 +52,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
[Authorize(Roles = RoleNames.Host)]
|
||||
public Tenant Put(int id, [FromBody] Tenant tenant)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
@ -65,7 +65,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// DELETE api/<controller>/5
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
[Authorize(Roles = RoleNames.Host)]
|
||||
public void Delete(int id)
|
||||
{
|
||||
_tenants.DeleteTenant(id);
|
||||
|
@ -34,14 +34,14 @@ namespace Oqtane.Controllers
|
||||
|
||||
// GET: api/<controller>
|
||||
[HttpGet]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
[Authorize(Roles = RoleNames.Registered)]
|
||||
public IEnumerable<Theme> Get()
|
||||
{
|
||||
return _themes.GetThemes();
|
||||
}
|
||||
|
||||
[HttpGet("install")]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
[Authorize(Roles = RoleNames.Host)]
|
||||
public void InstallThemes()
|
||||
{
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Themes Installed");
|
||||
@ -50,7 +50,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// DELETE api/<controller>/xxx
|
||||
[HttpDelete("{themename}")]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
[Authorize(Roles = RoleNames.Host)]
|
||||
public void Delete(string themename)
|
||||
{
|
||||
List<Theme> themes = _themes.GetThemes().ToList();
|
||||
|
@ -77,7 +77,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
private User Filter(User user)
|
||||
{
|
||||
if (user != null && !User.IsInRole(Constants.AdminRole) && User.Identity.Name?.ToLower() != user.Username.ToLower())
|
||||
if (user != null && !User.IsInRole(RoleNames.Admin) && User.Identity.Name?.ToLower() != user.Username.ToLower())
|
||||
{
|
||||
user.DisplayName = "";
|
||||
user.Email = "";
|
||||
@ -118,7 +118,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
bool verified;
|
||||
bool allowregistration;
|
||||
if (user.Username == Constants.HostUser || User.IsInRole(Constants.AdminRole))
|
||||
if (user.Username == Constants.HostUser || User.IsInRole(RoleNames.Admin))
|
||||
{
|
||||
verified = true;
|
||||
allowregistration = true;
|
||||
@ -166,7 +166,7 @@ namespace Oqtane.Controllers
|
||||
// assign to host role if this is the host user ( initial installation )
|
||||
if (user.Username == Constants.HostUser)
|
||||
{
|
||||
int hostroleid = _roles.GetRoles(user.SiteId, true).Where(item => item.Name == Constants.HostRole).FirstOrDefault().RoleId;
|
||||
int hostroleid = _roles.GetRoles(user.SiteId, true).Where(item => item.Name == RoleNames.Host).FirstOrDefault().RoleId;
|
||||
UserRole userrole = new UserRole();
|
||||
userrole.UserId = newUser.UserId;
|
||||
userrole.RoleId = hostroleid;
|
||||
@ -190,7 +190,7 @@ namespace Oqtane.Controllers
|
||||
Permissions = new List<Permission>
|
||||
{
|
||||
new Permission(PermissionNames.Browse, newUser.UserId, true),
|
||||
new Permission(PermissionNames.View, Constants.AllUsersRole, true),
|
||||
new Permission(PermissionNames.View, RoleNames.Everyone, true),
|
||||
new Permission(PermissionNames.Edit, newUser.UserId, true)
|
||||
}.EncodePermissions()
|
||||
});
|
||||
@ -242,7 +242,7 @@ namespace Oqtane.Controllers
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
if (User.IsInRole(Constants.AdminRole) || User.Identity.Name == user.Username)
|
||||
if (User.IsInRole(RoleNames.Admin) || User.Identity.Name == user.Username)
|
||||
{
|
||||
if (user.Password != "")
|
||||
{
|
||||
@ -270,7 +270,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// DELETE api/<controller>/5?siteid=x
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Roles = Constants.AdminRole)]
|
||||
[Authorize(Roles = RoleNames.Admin)]
|
||||
public async Task Delete(int id)
|
||||
{
|
||||
IdentityUser identityuser = await _identityUserManager.FindByNameAsync(_users.GetUser(id).Username);
|
||||
@ -460,9 +460,9 @@ namespace Oqtane.Controllers
|
||||
foreach (UserRole userrole in userroles)
|
||||
{
|
||||
roles += userrole.Role.Name + ";";
|
||||
if (userrole.Role.Name == Constants.HostRole && userroles.Where(item => item.Role.Name == Constants.AdminRole).FirstOrDefault() == null)
|
||||
if (userrole.Role.Name == RoleNames.Host && userroles.Where(item => item.Role.Name == RoleNames.Admin).FirstOrDefault() == null)
|
||||
{
|
||||
roles += Constants.AdminRole + ";";
|
||||
roles += RoleNames.Admin + ";";
|
||||
}
|
||||
}
|
||||
if (roles != "") roles = ";" + roles;
|
||||
|
@ -27,7 +27,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// GET: api/<controller>?siteid=x
|
||||
[HttpGet]
|
||||
[Authorize(Roles = Constants.AdminRole)]
|
||||
[Authorize(Roles = RoleNames.Admin)]
|
||||
public IEnumerable<UserRole> Get(string siteid)
|
||||
{
|
||||
return _userRoles.GetUserRoles(int.Parse(siteid));
|
||||
@ -35,7 +35,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// GET api/<controller>/5
|
||||
[HttpGet("{id}")]
|
||||
[Authorize(Roles = Constants.AdminRole)]
|
||||
[Authorize(Roles = RoleNames.Admin)]
|
||||
public UserRole Get(int id)
|
||||
{
|
||||
return _userRoles.GetUserRole(id);
|
||||
@ -43,7 +43,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// POST api/<controller>
|
||||
[HttpPost]
|
||||
[Authorize(Roles = Constants.AdminRole)]
|
||||
[Authorize(Roles = RoleNames.Admin)]
|
||||
public UserRole Post([FromBody] UserRole userRole)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
@ -57,7 +57,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Roles = Constants.AdminRole)]
|
||||
[Authorize(Roles = RoleNames.Admin)]
|
||||
public UserRole Put(int id, [FromBody] UserRole userRole)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
@ -71,7 +71,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
// DELETE api/<controller>/5
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Roles = Constants.AdminRole)]
|
||||
[Authorize(Roles = RoleNames.Admin)]
|
||||
public void Delete(int id)
|
||||
{
|
||||
UserRole userRole = _userRoles.GetUserRole(id);
|
||||
|
Reference in New Issue
Block a user