From fcf0b608816fdb4c21eacbb2210b9616d979b777 Mon Sep 17 00:00:00 2001 From: Lucio Maranta Date: Tue, 27 Feb 2018 14:16:51 +0100 Subject: [PATCH] Removed logout functionality and added general functionality --- .../Controllers/FunctionsAccessController.cs | 2 +- Step.Database/DatabaseContext.cs | 2 +- Step.Database/Migrations/Configuration.cs | 11 +++++------ Step/Controllers/WebApi/UserController.cs | 6 +++--- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Step.Database/Controllers/FunctionsAccessController.cs b/Step.Database/Controllers/FunctionsAccessController.cs index 00126c7e..af524d50 100644 --- a/Step.Database/Controllers/FunctionsAccessController.cs +++ b/Step.Database/Controllers/FunctionsAccessController.cs @@ -64,7 +64,7 @@ namespace Step.Database.Controllers Id = x.FunctionAccessId, Area = x.Area, Name = x.Name, - Enabled = false + Enabled = x.PlcId != -1 ? false : x.Enabled // Only PLC function has to be false }) .ToList(); } diff --git a/Step.Database/DatabaseContext.cs b/Step.Database/DatabaseContext.cs index 610615f3..4f286f0b 100644 --- a/Step.Database/DatabaseContext.cs +++ b/Step.Database/DatabaseContext.cs @@ -62,7 +62,7 @@ namespace Step.Database { maintenancesController.CheckDifferencesFromDbAndXml(); } - + // Get functionality and PLC default false functionality using (FunctionsAccessController functionsAccess = new FunctionsAccessController()) { FunctionsAccessConfig = functionsAccess.FindAll(); diff --git a/Step.Database/Migrations/Configuration.cs b/Step.Database/Migrations/Configuration.cs index e71df2f6..9dbdacaa 100644 --- a/Step.Database/Migrations/Configuration.cs +++ b/Step.Database/Migrations/Configuration.cs @@ -23,12 +23,11 @@ namespace Step.Database.Migrations context.FunctionsAccess.AddOrUpdate( // General Function - new FunctionAccessModel() { FunctionAccessId = 1, Name = "functionAccess", Area = AREAS.GENERAL_KEY, Enabled = true, WriteLevelMin = 100, ReadLevelMin = 1, PlcId = -1 }, - new FunctionAccessModel() { FunctionAccessId = 2, Name = "logout", Area = AREAS.GENERAL_KEY, Enabled = true, WriteLevelMin = 1, ReadLevelMin = 1, PlcId = -1 }, - new FunctionAccessModel() { FunctionAccessId = 3, Name = "userData", Area = AREAS.GENERAL_KEY, Enabled = true, WriteLevelMin = 1, ReadLevelMin = 1, PlcId = -1 }, - new FunctionAccessModel() { FunctionAccessId = 4, Name = "ncData", Area = AREAS.GENERAL_KEY, Enabled = true, WriteLevelMin = 10, ReadLevelMin = 1, PlcId = -1 }, - new FunctionAccessModel() { FunctionAccessId = 5, Name = "startupIcons", Area = AREAS.GENERAL_KEY, Enabled = true, WriteLevelMin = 1, ReadLevelMin = 1, PlcId = 0 }, - new FunctionAccessModel() { FunctionAccessId = 6, Name = "alarmCmd", Area = AREAS.GENERAL_KEY, Enabled = true, WriteLevelMin = 1, ReadLevelMin = 1, PlcId = 1 } + new FunctionAccessModel() { FunctionAccessId = 1, Name = "general", Area = AREAS.GENERAL_KEY, Enabled = true, WriteLevelMin = 100, ReadLevelMin = 1, PlcId = -1 }, + new FunctionAccessModel() { FunctionAccessId = 2, Name = "userFunctions", Area = AREAS.GENERAL_KEY, Enabled = true, WriteLevelMin = 1, ReadLevelMin = 1, PlcId = -1 }, + new FunctionAccessModel() { FunctionAccessId = 3, Name = "ncData", Area = AREAS.GENERAL_KEY, Enabled = true, WriteLevelMin = 10, ReadLevelMin = 1, PlcId = -1 }, + new FunctionAccessModel() { FunctionAccessId = 4, Name = "startupIcons", Area = AREAS.GENERAL_KEY, Enabled = true, WriteLevelMin = 1, ReadLevelMin = 1, PlcId = 0 }, + new FunctionAccessModel() { FunctionAccessId = 5, Name = "alarmCmd", Area = AREAS.GENERAL_KEY, Enabled = true, WriteLevelMin = 1, ReadLevelMin = 1, PlcId = 1 } ); context.SaveChanges(); diff --git a/Step/Controllers/WebApi/UserController.cs b/Step/Controllers/WebApi/UserController.cs index a32e78bf..1bb3b793 100644 --- a/Step/Controllers/WebApi/UserController.cs +++ b/Step/Controllers/WebApi/UserController.cs @@ -16,7 +16,7 @@ namespace Step.Controllers.WebApi public class UserController : ApiController { [Route("logout"), HttpPost] - [WebApiAuthorize(FunctionAccess = "logout", Action = ACTIONS.WRITE)] + [WebApiAuthorize(FunctionAccess = "userFunctions", Action = ACTIONS.WRITE)] public IHttpActionResult Logout() { var identity = User.Identity as ClaimsIdentity; @@ -49,7 +49,7 @@ namespace Step.Controllers.WebApi } [Route("info"), HttpGet] - [WebApiAuthorize(FunctionAccess = "userData", Action = ACTIONS.READ)] + [WebApiAuthorize(FunctionAccess = "userFunctions", Action = ACTIONS.READ)] public IHttpActionResult UserInfo() { var identity = User.Identity as ClaimsIdentity; @@ -65,7 +65,7 @@ namespace Step.Controllers.WebApi } [Route("language"), HttpPut] - [WebApiAuthorize(FunctionAccess = "userData", Action = ACTIONS.READ)] + [WebApiAuthorize(FunctionAccess = "userFunctions", Action = ACTIONS.READ)] public IHttpActionResult PutUserLanguage([FromBody] dynamic user) { // If no body return 400