structured logging
This commit is contained in:
@ -4,7 +4,7 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Shared;
|
||||
using System.Linq;
|
||||
using Oqtane.Infrastructure;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
@ -12,10 +12,12 @@ namespace Oqtane.Controllers
|
||||
public class AliasController : Controller
|
||||
{
|
||||
private readonly IAliasRepository Aliases;
|
||||
private readonly ILogManager logger;
|
||||
|
||||
public AliasController(IAliasRepository Aliases)
|
||||
public AliasController(IAliasRepository Aliases, ILogManager logger)
|
||||
{
|
||||
this.Aliases = Aliases;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
// GET: api/<controller>
|
||||
@ -40,6 +42,7 @@ namespace Oqtane.Controllers
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Alias = Aliases.AddAlias(Alias);
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Alias Added {Alias}", Alias);
|
||||
}
|
||||
return Alias;
|
||||
}
|
||||
@ -52,6 +55,7 @@ namespace Oqtane.Controllers
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Alias = Aliases.UpdateAlias(Alias);
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Alias Updated {Alias}", Alias);
|
||||
}
|
||||
return Alias;
|
||||
}
|
||||
@ -62,6 +66,7 @@ namespace Oqtane.Controllers
|
||||
public void Delete(int id)
|
||||
{
|
||||
Aliases.DeleteAlias(id);
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Alias Deleted {AliasId}", id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Oqtane.Infrastructure;
|
||||
using Oqtane.Shared;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -15,11 +16,13 @@ namespace Oqtane.Controllers
|
||||
public class FileController : Controller
|
||||
{
|
||||
private readonly IWebHostEnvironment environment;
|
||||
private readonly ILogManager logger;
|
||||
private readonly string WhiteList = "jpg,jpeg,jpe,gif,bmp,png,mov,wmv,avi,mp4,mp3,doc,docx,xls,xlsx,ppt,pptx,pdf,txt,zip,nupkg";
|
||||
|
||||
public FileController(IWebHostEnvironment environment)
|
||||
public FileController(IWebHostEnvironment environment, ILogManager logger)
|
||||
{
|
||||
this.environment = environment;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
// GET: api/<controller>?folder=x
|
||||
@ -107,6 +110,7 @@ namespace Oqtane.Controllers
|
||||
{
|
||||
// rename file now that the entire process is completed
|
||||
System.IO.File.Move(Path.Combine(folder, filename + ".tmp"), Path.Combine(folder, filename));
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "File Uploaded {File}", Path.Combine(folder, filename));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -169,6 +173,7 @@ namespace Oqtane.Controllers
|
||||
if (System.IO.File.Exists(file))
|
||||
{
|
||||
System.IO.File.Delete(file);
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "File Deleted {File}", file);
|
||||
}
|
||||
}
|
||||
|
||||
|
39
Oqtane.Server/Controllers/LogController.cs
Normal file
39
Oqtane.Server/Controllers/LogController.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Oqtane.Models;
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Infrastructure;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
|
||||
[Route("{site}/api/[controller]")]
|
||||
public class LogController : Controller
|
||||
{
|
||||
private readonly ILogManager Logger;
|
||||
private readonly ILogRepository Logs;
|
||||
|
||||
public LogController(ILogManager Logger, ILogRepository Logs)
|
||||
{
|
||||
this.Logger = Logger;
|
||||
this.Logs = Logs;
|
||||
}
|
||||
|
||||
// GET: api/<controller>?siteid=x
|
||||
[HttpGet]
|
||||
public IEnumerable<Log> Get(string siteid)
|
||||
{
|
||||
return Logs.GetLogs(int.Parse(siteid));
|
||||
}
|
||||
|
||||
// POST api/<controller>
|
||||
[HttpPost]
|
||||
public void Post([FromBody] Log Log)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Logger.AddLog(Log);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -10,6 +10,7 @@ using System;
|
||||
using Oqtane.Modules;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System.Text.Json;
|
||||
using Oqtane.Infrastructure;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
@ -20,13 +21,15 @@ namespace Oqtane.Controllers
|
||||
private readonly IPageModuleRepository PageModules;
|
||||
private readonly IModuleDefinitionRepository ModuleDefinitions;
|
||||
private readonly IServiceProvider ServiceProvider;
|
||||
private readonly ILogManager logger;
|
||||
|
||||
public ModuleController(IModuleRepository Modules, IPageModuleRepository PageModules, IModuleDefinitionRepository ModuleDefinitions, IServiceProvider ServiceProvider)
|
||||
public ModuleController(IModuleRepository Modules, IPageModuleRepository PageModules, IModuleDefinitionRepository ModuleDefinitions, IServiceProvider ServiceProvider, ILogManager logger)
|
||||
{
|
||||
this.Modules = Modules;
|
||||
this.PageModules = PageModules;
|
||||
this.ModuleDefinitions = ModuleDefinitions;
|
||||
this.ServiceProvider = ServiceProvider;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
// GET: api/<controller>?siteid=x
|
||||
@ -73,6 +76,7 @@ namespace Oqtane.Controllers
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Module = Modules.AddModule(Module);
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Module Added {Module}", Module);
|
||||
}
|
||||
return Module;
|
||||
}
|
||||
@ -85,6 +89,7 @@ namespace Oqtane.Controllers
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Module = Modules.UpdateModule(Module);
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Module Updated {Module}", Module);
|
||||
}
|
||||
return Module;
|
||||
}
|
||||
@ -95,6 +100,7 @@ namespace Oqtane.Controllers
|
||||
public void Delete(int id)
|
||||
{
|
||||
Modules.DeleteModule(id);
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Module Deleted {ModuleId}", id);
|
||||
}
|
||||
|
||||
// GET api/<controller>/export?moduleid=x
|
||||
@ -135,6 +141,7 @@ namespace Oqtane.Controllers
|
||||
}
|
||||
}
|
||||
content = JsonSerializer.Serialize(modulecontent);
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Module Content Exported {ModuleId}", moduleid);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -180,6 +187,7 @@ namespace Oqtane.Controllers
|
||||
var moduleobject = ActivatorUtilities.CreateInstance(ServiceProvider, moduletype);
|
||||
((IPortable)moduleobject).ImportModule(module, modulecontent.Content, modulecontent.Version);
|
||||
success = true;
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Module Content Imported {ModuleId}", moduleid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,12 +18,14 @@ namespace Oqtane.Controllers
|
||||
private readonly IModuleDefinitionRepository ModuleDefinitions;
|
||||
private readonly IInstallationManager InstallationManager;
|
||||
private readonly IWebHostEnvironment environment;
|
||||
private readonly ILogManager logger;
|
||||
|
||||
public ModuleDefinitionController(IModuleDefinitionRepository ModuleDefinitions, IInstallationManager InstallationManager, IWebHostEnvironment environment)
|
||||
public ModuleDefinitionController(IModuleDefinitionRepository ModuleDefinitions, IInstallationManager InstallationManager, IWebHostEnvironment environment, ILogManager logger)
|
||||
{
|
||||
this.ModuleDefinitions = ModuleDefinitions;
|
||||
this.InstallationManager = InstallationManager;
|
||||
this.environment = environment;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
// GET: api/<controller>?siteid=x
|
||||
@ -50,6 +52,7 @@ namespace Oqtane.Controllers
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
ModuleDefinitions.UpdateModuleDefinition(ModuleDefinition);
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Module Definition Updated {ModuleDefinition}", ModuleDefinition);
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,6 +61,7 @@ namespace Oqtane.Controllers
|
||||
public void InstallModules()
|
||||
{
|
||||
InstallationManager.InstallPackages("Modules");
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Modules Installed");
|
||||
}
|
||||
|
||||
// DELETE api/<controller>/5?siteid=x
|
||||
@ -84,6 +88,7 @@ namespace Oqtane.Controllers
|
||||
}
|
||||
|
||||
ModuleDefinitions.DeleteModuleDefinition(id, siteid);
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Module Deleted {ModuleDefinitionId}", id);
|
||||
|
||||
InstallationManager.RestartApplication();
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ using Oqtane.Repository;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Shared;
|
||||
using System.Linq;
|
||||
using Oqtane.Infrastructure;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
@ -12,10 +13,12 @@ namespace Oqtane.Controllers
|
||||
public class PageController : Controller
|
||||
{
|
||||
private readonly IPageRepository Pages;
|
||||
private readonly ILogManager logger;
|
||||
|
||||
public PageController(IPageRepository Pages)
|
||||
public PageController(IPageRepository Pages, ILogManager logger)
|
||||
{
|
||||
this.Pages = Pages;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
// GET: api/<controller>?siteid=x
|
||||
@ -47,6 +50,7 @@ namespace Oqtane.Controllers
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Page = Pages.AddPage(Page);
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Page Added {Page}", Page);
|
||||
}
|
||||
return Page;
|
||||
}
|
||||
@ -59,6 +63,7 @@ namespace Oqtane.Controllers
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Page = Pages.UpdatePage(Page);
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Page Updated {Page}", Page);
|
||||
}
|
||||
return Page;
|
||||
}
|
||||
@ -79,6 +84,7 @@ namespace Oqtane.Controllers
|
||||
}
|
||||
order += 2;
|
||||
}
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Page Order Updated {SiteId} {ParentId}", siteid, parentid);
|
||||
}
|
||||
|
||||
// DELETE api/<controller>/5
|
||||
@ -87,6 +93,7 @@ namespace Oqtane.Controllers
|
||||
public void Delete(int id)
|
||||
{
|
||||
Pages.DeletePage(id);
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Page Deleted {PageId}", id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ using Oqtane.Repository;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Shared;
|
||||
using System.Linq;
|
||||
using Oqtane.Infrastructure;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
@ -13,11 +14,13 @@ namespace Oqtane.Controllers
|
||||
{
|
||||
private readonly IPageModuleRepository PageModules;
|
||||
private readonly IModuleRepository Modules;
|
||||
private readonly ILogManager logger;
|
||||
|
||||
public PageModuleController(IPageModuleRepository PageModules, IModuleRepository Modules)
|
||||
public PageModuleController(IPageModuleRepository PageModules, IModuleRepository Modules, ILogManager logger)
|
||||
{
|
||||
this.PageModules = PageModules;
|
||||
this.Modules = Modules;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
// GET: api/<controller>
|
||||
@ -42,6 +45,7 @@ namespace Oqtane.Controllers
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
PageModule = PageModules.AddPageModule(PageModule);
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Page Module Added {PageModule}", PageModule);
|
||||
}
|
||||
return PageModule;
|
||||
}
|
||||
@ -54,6 +58,7 @@ namespace Oqtane.Controllers
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
PageModule = PageModules.UpdatePageModule(PageModule);
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Page Module Updated {PageModule}", PageModule);
|
||||
}
|
||||
return PageModule;
|
||||
}
|
||||
@ -74,6 +79,7 @@ namespace Oqtane.Controllers
|
||||
}
|
||||
order += 2;
|
||||
}
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Page Module Order Updated {PageId} {Pane}", pageid, pane);
|
||||
}
|
||||
|
||||
// DELETE api/<controller>/5
|
||||
@ -82,6 +88,7 @@ namespace Oqtane.Controllers
|
||||
public void Delete(int id)
|
||||
{
|
||||
PageModules.DeletePageModule(id);
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Page Module Deleted {PageModuleId}", id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Shared;
|
||||
using Oqtane.Infrastructure;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
@ -11,10 +12,12 @@ namespace Oqtane.Controllers
|
||||
public class PermissionController : Controller
|
||||
{
|
||||
private readonly IPermissionRepository Permissions;
|
||||
private readonly ILogManager logger;
|
||||
|
||||
public PermissionController(IPermissionRepository Permissions)
|
||||
public PermissionController(IPermissionRepository Permissions, ILogManager logger)
|
||||
{
|
||||
this.Permissions = Permissions;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
// GET: api/<controller>
|
||||
@ -39,6 +42,7 @@ namespace Oqtane.Controllers
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Permission = Permissions.AddPermission(Permission);
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Permission Added {Permission}", Permission);
|
||||
}
|
||||
return Permission;
|
||||
}
|
||||
@ -51,6 +55,7 @@ namespace Oqtane.Controllers
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Permission = Permissions.UpdatePermission(Permission);
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Permission Updated {Permission}", Permission);
|
||||
}
|
||||
return Permission;
|
||||
}
|
||||
@ -61,6 +66,7 @@ namespace Oqtane.Controllers
|
||||
public void Delete(int id)
|
||||
{
|
||||
Permissions.DeletePermission(id);
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Permission Deleted {PermissionId}", id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Shared;
|
||||
using Oqtane.Infrastructure;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
@ -11,10 +12,12 @@ namespace Oqtane.Controllers
|
||||
public class ProfileController : Controller
|
||||
{
|
||||
private readonly IProfileRepository Profiles;
|
||||
private readonly ILogManager logger;
|
||||
|
||||
public ProfileController(IProfileRepository Profiles)
|
||||
public ProfileController(IProfileRepository Profiles, ILogManager logger)
|
||||
{
|
||||
this.Profiles = Profiles;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
// GET: api/<controller>?siteid=x
|
||||
@ -46,6 +49,7 @@ namespace Oqtane.Controllers
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Profile = Profiles.AddProfile(Profile);
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Profile Added {Profile}", Profile);
|
||||
}
|
||||
return Profile;
|
||||
}
|
||||
@ -58,6 +62,7 @@ namespace Oqtane.Controllers
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Profile = Profiles.UpdateProfile(Profile);
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Profile Updated {Profile}", Profile);
|
||||
}
|
||||
return Profile;
|
||||
}
|
||||
@ -68,6 +73,7 @@ namespace Oqtane.Controllers
|
||||
public void Delete(int id)
|
||||
{
|
||||
Profiles.DeleteProfile(id);
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Profile Deleted {ProfileId}", id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Shared;
|
||||
using Oqtane.Infrastructure;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
@ -11,10 +12,12 @@ namespace Oqtane.Controllers
|
||||
public class RoleController : Controller
|
||||
{
|
||||
private readonly IRoleRepository Roles;
|
||||
private readonly ILogManager logger;
|
||||
|
||||
public RoleController(IRoleRepository Roles)
|
||||
public RoleController(IRoleRepository Roles, ILogManager logger)
|
||||
{
|
||||
this.Roles = Roles;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
// GET: api/<controller>?siteid=x
|
||||
@ -46,6 +49,7 @@ namespace Oqtane.Controllers
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Role = Roles.AddRole(Role);
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Role Added {Role}", Role);
|
||||
}
|
||||
return Role;
|
||||
}
|
||||
@ -58,6 +62,7 @@ namespace Oqtane.Controllers
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Role = Roles.UpdateRole(Role);
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Role Updated {Role}", Role);
|
||||
}
|
||||
return Role;
|
||||
}
|
||||
@ -68,6 +73,7 @@ namespace Oqtane.Controllers
|
||||
public void Delete(int id)
|
||||
{
|
||||
Roles.DeleteRole(id);
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Role Deleted {RoleId}", id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ using Oqtane.Repository;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Shared;
|
||||
using Oqtane.Security;
|
||||
using Oqtane.Infrastructure;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
@ -13,11 +14,13 @@ namespace Oqtane.Controllers
|
||||
{
|
||||
private readonly ISettingRepository Settings;
|
||||
private readonly IUserPermissions UserPermissions;
|
||||
private readonly ILogManager logger;
|
||||
|
||||
public SettingController(ISettingRepository Settings, IUserPermissions UserPermissions)
|
||||
public SettingController(ISettingRepository Settings, IUserPermissions UserPermissions, ILogManager logger)
|
||||
{
|
||||
this.Settings = Settings;
|
||||
this.UserPermissions = UserPermissions;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
// GET: api/<controller>
|
||||
@ -42,6 +45,7 @@ namespace Oqtane.Controllers
|
||||
if (ModelState.IsValid && IsAuthorized(Setting.EntityName, Setting.EntityId))
|
||||
{
|
||||
Setting = Settings.AddSetting(Setting);
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Setting Added {Setting}", Setting);
|
||||
}
|
||||
return Setting;
|
||||
}
|
||||
@ -54,6 +58,7 @@ namespace Oqtane.Controllers
|
||||
if (ModelState.IsValid && IsAuthorized(Setting.EntityName, Setting.EntityId))
|
||||
{
|
||||
Setting = Settings.UpdateSetting(Setting);
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Setting Updated {Setting}", Setting);
|
||||
}
|
||||
return Setting;
|
||||
}
|
||||
@ -64,6 +69,7 @@ namespace Oqtane.Controllers
|
||||
public void Delete(int id)
|
||||
{
|
||||
Settings.DeleteSetting(id);
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Setting Deleted {SettingId}", id);
|
||||
}
|
||||
|
||||
private bool IsAuthorized(string EntityName, int EntityId)
|
||||
|
@ -7,6 +7,7 @@ using Oqtane.Shared;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Oqtane.Infrastructure;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
@ -16,12 +17,14 @@ namespace Oqtane.Controllers
|
||||
private readonly ISiteRepository Sites;
|
||||
private readonly ITenantResolver Tenants;
|
||||
private readonly IWebHostEnvironment environment;
|
||||
private readonly ILogManager logger;
|
||||
|
||||
public SiteController(ISiteRepository Sites, ITenantResolver Tenants, IWebHostEnvironment environment)
|
||||
public SiteController(ISiteRepository Sites, ITenantResolver Tenants, IWebHostEnvironment environment, ILogManager logger)
|
||||
{
|
||||
this.Sites = Sites;
|
||||
this.Tenants = Tenants;
|
||||
this.environment = environment;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
// GET: api/<controller>
|
||||
@ -61,6 +64,7 @@ namespace Oqtane.Controllers
|
||||
{
|
||||
Directory.CreateDirectory(folder);
|
||||
}
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Site Added {Site}", Site);
|
||||
}
|
||||
}
|
||||
return Site;
|
||||
@ -74,6 +78,7 @@ namespace Oqtane.Controllers
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Site = Sites.UpdateSite(Site);
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Site Updated {Site}", Site);
|
||||
}
|
||||
return Site;
|
||||
}
|
||||
@ -84,6 +89,7 @@ namespace Oqtane.Controllers
|
||||
public void Delete(int id)
|
||||
{
|
||||
Sites.DeleteSite(id);
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Site Deleted {SiteId}", id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ using Oqtane.Repository;
|
||||
using Oqtane.Models;
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Shared;
|
||||
using Oqtane.Infrastructure;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
@ -11,10 +12,12 @@ namespace Oqtane.Controllers
|
||||
public class TenantController : Controller
|
||||
{
|
||||
private readonly ITenantRepository Tenants;
|
||||
private readonly ILogManager logger;
|
||||
|
||||
public TenantController(ITenantRepository Tenants)
|
||||
public TenantController(ITenantRepository Tenants, ILogManager logger)
|
||||
{
|
||||
this.Tenants = Tenants;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
// GET: api/<controller>
|
||||
@ -39,6 +42,7 @@ namespace Oqtane.Controllers
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Tenant = Tenants.AddTenant(Tenant);
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Tenant Added {TenantId}", Tenant.TenantId);
|
||||
}
|
||||
return Tenant;
|
||||
}
|
||||
@ -51,6 +55,7 @@ namespace Oqtane.Controllers
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Tenant = Tenants.UpdateTenant(Tenant);
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Tenant Updated {TenantId}", Tenant.TenantId);
|
||||
}
|
||||
return Tenant;
|
||||
}
|
||||
@ -61,6 +66,7 @@ namespace Oqtane.Controllers
|
||||
public void Delete(int id)
|
||||
{
|
||||
Tenants.DeleteTenant(id);
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Tenant Deleted {TenantId}", id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,12 +18,14 @@ namespace Oqtane.Controllers
|
||||
private readonly IThemeRepository Themes;
|
||||
private readonly IInstallationManager InstallationManager;
|
||||
private readonly IWebHostEnvironment environment;
|
||||
private readonly ILogManager logger;
|
||||
|
||||
public ThemeController(IThemeRepository Themes, IInstallationManager InstallationManager, IWebHostEnvironment environment)
|
||||
public ThemeController(IThemeRepository Themes, IInstallationManager InstallationManager, IWebHostEnvironment environment, ILogManager logger)
|
||||
{
|
||||
this.Themes = Themes;
|
||||
this.InstallationManager = InstallationManager;
|
||||
this.environment = environment;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
// GET: api/<controller>
|
||||
@ -47,6 +49,7 @@ namespace Oqtane.Controllers
|
||||
public void InstallThemes()
|
||||
{
|
||||
InstallationManager.InstallPackages("Themes");
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Themes Installed");
|
||||
}
|
||||
|
||||
// DELETE api/<controller>/xxx
|
||||
@ -71,6 +74,7 @@ namespace Oqtane.Controllers
|
||||
{
|
||||
System.IO.File.Delete(file);
|
||||
}
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Theme Deleted {ThemeName}", themename);
|
||||
|
||||
InstallationManager.RestartApplication();
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ using System.Threading.Tasks;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using Oqtane.Shared;
|
||||
using Oqtane.Infrastructure;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
@ -20,14 +21,16 @@ namespace Oqtane.Controllers
|
||||
private readonly IUserRoleRepository UserRoles;
|
||||
private readonly UserManager<IdentityUser> IdentityUserManager;
|
||||
private readonly SignInManager<IdentityUser> IdentitySignInManager;
|
||||
private readonly ILogManager logger;
|
||||
|
||||
public UserController(IUserRepository Users, IRoleRepository Roles, IUserRoleRepository UserRoles, UserManager<IdentityUser> IdentityUserManager, SignInManager<IdentityUser> IdentitySignInManager)
|
||||
public UserController(IUserRepository Users, IRoleRepository Roles, IUserRoleRepository UserRoles, UserManager<IdentityUser> IdentityUserManager, SignInManager<IdentityUser> IdentitySignInManager, ILogManager logger)
|
||||
{
|
||||
this.Users = Users;
|
||||
this.Roles = Roles;
|
||||
this.UserRoles = UserRoles;
|
||||
this.IdentityUserManager = IdentityUserManager;
|
||||
this.IdentitySignInManager = IdentitySignInManager;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
// GET: api/<controller>?siteid=x
|
||||
@ -123,6 +126,8 @@ namespace Oqtane.Controllers
|
||||
UserRoles.AddUserRole(userrole);
|
||||
}
|
||||
}
|
||||
user.Password = ""; // remove sensitive information
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "User Added {User}", user);
|
||||
}
|
||||
|
||||
return user;
|
||||
@ -145,6 +150,8 @@ namespace Oqtane.Controllers
|
||||
}
|
||||
}
|
||||
User = Users.UpdateUser(User);
|
||||
User.Password = ""; // remove sensitive information
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "User Updated {User}", User);
|
||||
}
|
||||
return User;
|
||||
}
|
||||
@ -163,6 +170,7 @@ namespace Oqtane.Controllers
|
||||
if (result != null)
|
||||
{
|
||||
Users.DeleteUser(id);
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "User Deleted {UserId}", id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -185,12 +193,17 @@ namespace Oqtane.Controllers
|
||||
if (user != null)
|
||||
{
|
||||
user.IsAuthenticated = true;
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "User Login Successful {Username}", User.Username);
|
||||
if (SetCookie)
|
||||
{
|
||||
await IdentitySignInManager.SignInAsync(identityuser, IsPersistent);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Error, "User Login Failed {Username}", User.Username);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -203,6 +216,7 @@ namespace Oqtane.Controllers
|
||||
public async Task Logout([FromBody] User User)
|
||||
{
|
||||
await HttpContext.SignOutAsync(IdentityConstants.ApplicationScheme);
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "User Logout {Username}", User.Username);
|
||||
}
|
||||
|
||||
// GET api/<controller>/current
|
||||
|
@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Shared;
|
||||
using Oqtane.Infrastructure;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
@ -11,10 +12,12 @@ namespace Oqtane.Controllers
|
||||
public class UserRoleController : Controller
|
||||
{
|
||||
private readonly IUserRoleRepository UserRoles;
|
||||
private readonly ILogManager logger;
|
||||
|
||||
public UserRoleController(IUserRoleRepository UserRoles)
|
||||
public UserRoleController(IUserRoleRepository UserRoles, ILogManager logger)
|
||||
{
|
||||
this.UserRoles = UserRoles;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
// GET: api/<controller>?userid=x
|
||||
@ -46,6 +49,7 @@ namespace Oqtane.Controllers
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
UserRole = UserRoles.AddUserRole(UserRole);
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "User Role Added {UserRole}", UserRole);
|
||||
}
|
||||
return UserRole;
|
||||
}
|
||||
@ -58,6 +62,7 @@ namespace Oqtane.Controllers
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
UserRole = UserRoles.UpdateUserRole(UserRole);
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "User Role Updated {UserRole}", UserRole);
|
||||
}
|
||||
return UserRole;
|
||||
}
|
||||
@ -68,6 +73,7 @@ namespace Oqtane.Controllers
|
||||
public void Delete(int id)
|
||||
{
|
||||
UserRoles.DeleteUserRole(id);
|
||||
logger.AddLog(this.GetType().FullName, LogLevel.Information, "User Role Deleted {UserRoleId}", id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user