diff --git a/devdocs/todo.txt b/devdocs/todo.txt index 5321fab2..9f84542e 100644 --- a/devdocs/todo.txt +++ b/devdocs/todo.txt @@ -7,12 +7,6 @@ eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOiIxNTcxODU5OTU0IiwiZXhwIjoiMTU3MjQ - - -TODO: License.cs using httpclient directly albeit trying to do it right` - - Change to use httpclientfactory injected service: - - https://docs.microsoft.com/en-us/aspnet/core/fundamentals/http-requests?view=aspnetcore-3.1 - TODO: Need route to gather all object role rights in a format useful to display in UI so that a biz manager can see at a glance the rights for different roles to objects - This way it's dynamic and picked up from the code itself which is always the source of truth so no need to put in the manual - Would likely want to display multiple ways: for a specific object or role or selected user maybe too in the user info form ("effective roles") diff --git a/server/AyaNova/Controllers/AuthorizationRolesController.cs b/server/AyaNova/Controllers/AuthorizationRolesController.cs new file mode 100644 index 00000000..14a0c8bf --- /dev/null +++ b/server/AyaNova/Controllers/AuthorizationRolesController.cs @@ -0,0 +1,89 @@ +using System; +using System.Collections.Generic; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Routing; +using Microsoft.Extensions.Logging; +using Microsoft.AspNetCore.Authorization; +using AyaNova.Models; +using AyaNova.Api.ControllerHelpers; +using AyaNova.Biz; + + +namespace AyaNova.Api.Controllers +{ + + /// + /// Enum pick list controller + /// + [ApiController] + [ApiVersion("8.0")] + [Route("api/v{version:apiVersion}/[controller]")] + [Produces("application/json")] + [Authorize] + public class AuthorizationRolesController : ControllerBase + { + private readonly AyContext ct; + private readonly ILogger log; + private readonly ApiServerState serverState; + + + /// + /// ctor + /// + /// + /// + /// + public AuthorizationRolesController(AyContext dbcontext, ILogger logger, ApiServerState apiServerState) + { + ct = dbcontext; + log = logger; + serverState = apiServerState; + } + + + /// + /// Get roles + /// + /// Dictionary list of AyaNova object types and their authorization role rights in AyaNova + [HttpGet("list")] + public ActionResult GetRoles() + { + if (!serverState.IsOpen) + { + return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason)); + } + + + + return Ok(ApiOkResponse.Response(BizRoles.roles, true)); + } + + + + + // /// + // /// Get all possible enumerated values picklist key names + // /// + // /// List of AyaNova enumerated type list key names that can be fetched from the AyaEnumPickList/GetPickListRoute + // [HttpGet("listkeys")] + // public ActionResult GetTypesList() + // { + // if (!serverState.IsOpen) + // { + // return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason)); + // } + + // List> ret = new List>(); + // ret.Add(new KeyValuePair("usertypes", "AyaNova user account types")); + // ret.Add(new KeyValuePair("authorizationroles", "AyaNova user account role types")); + // ret.Add(new KeyValuePair("AyaType", "All AyaNova object types, use the AyaTypeController route to fetch these")); + // ret.Add(new KeyValuePair("datatypes", "Types of data used in AyaNova for display and formatting UI purposes")); + + // return Ok(ApiOkResponse.Response(ret, true)); + // } + + + + + }//eoc +}//ens \ No newline at end of file diff --git a/server/AyaNova/Startup.cs b/server/AyaNova/Startup.cs index 0e68aba4..cb0e8d94 100644 --- a/server/AyaNova/Startup.cs +++ b/server/AyaNova/Startup.cs @@ -413,7 +413,7 @@ namespace AyaNova // ******************** TESTING WIPE DB ***************************** // //Set this to true to wipe the db and reinstall a trial license and re-seed the data - var TESTING_REFRESH_DB = true;//####################################################################################### + var TESTING_REFRESH_DB = false;//####################################################################################### #if (DEBUG) diff --git a/server/AyaNova/biz/BizRoles.cs b/server/AyaNova/biz/BizRoles.cs index 008602ea..44c260b1 100644 --- a/server/AyaNova/biz/BizRoles.cs +++ b/server/AyaNova/biz/BizRoles.cs @@ -12,7 +12,7 @@ namespace AyaNova.Biz internal static class BizRoles { - static Dictionary roles = new Dictionary(); + internal static Dictionary roles = new Dictionary(); static BizRoles() {