This commit is contained in:
@@ -58,6 +58,7 @@ namespace AyaNova.Api.ControllerHelpers
|
|||||||
internal static bool HasAnyRole(AuthorizationRoles currentUserRoles, AyaType objectType)
|
internal static bool HasAnyRole(AuthorizationRoles currentUserRoles, AyaType objectType)
|
||||||
{
|
{
|
||||||
var RoleSet = BizRoles.GetRoleSet(objectType);
|
var RoleSet = BizRoles.GetRoleSet(objectType);
|
||||||
|
if (RoleSet == null) return false;
|
||||||
var AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change | RoleSet.Select;
|
var AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change | RoleSet.Select;
|
||||||
return currentUserRoles.HasAnyFlags(AllowedRoles);
|
return currentUserRoles.HasAnyFlags(AllowedRoles);
|
||||||
}
|
}
|
||||||
@@ -82,14 +83,17 @@ namespace AyaNova.Api.ControllerHelpers
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
internal static bool HasSelectRole(AuthorizationRoles currentUserRoles, AyaType objectType)
|
internal static bool HasSelectRole(AuthorizationRoles currentUserRoles, AyaType objectType)
|
||||||
{
|
{
|
||||||
|
var RoleSet = BizRoles.GetRoleSet(objectType);
|
||||||
|
if (RoleSet == null) return false;
|
||||||
|
|
||||||
//NOTE: this assumes that if you can change you can read
|
//NOTE: this assumes that if you can change you can read
|
||||||
if (currentUserRoles.HasAnyFlags(BizRoles.GetRoleSet(objectType).Change))
|
if (currentUserRoles.HasAnyFlags(RoleSet.Change))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (currentUserRoles.HasAnyFlags(BizRoles.GetRoleSet(objectType).ReadFullRecord))
|
if (currentUserRoles.HasAnyFlags(RoleSet.ReadFullRecord))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (currentUserRoles.HasAnyFlags(BizRoles.GetRoleSet(objectType).Select))
|
if (currentUserRoles.HasAnyFlags(RoleSet.Select))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -118,6 +122,7 @@ namespace AyaNova.Api.ControllerHelpers
|
|||||||
{
|
{
|
||||||
//NOTE: this assumes that if you can change you can read
|
//NOTE: this assumes that if you can change you can read
|
||||||
var RoleSet = BizRoles.GetRoleSet(objectType);
|
var RoleSet = BizRoles.GetRoleSet(objectType);
|
||||||
|
if (RoleSet == null) return false;
|
||||||
var AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change;
|
var AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change;
|
||||||
return currentUserRoles.HasAnyFlags(AllowedRoles);
|
return currentUserRoles.HasAnyFlags(AllowedRoles);
|
||||||
}
|
}
|
||||||
@@ -144,7 +149,9 @@ namespace AyaNova.Api.ControllerHelpers
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
internal static bool HasCreateRole(AuthorizationRoles currentUserRoles, AyaType objectType)
|
internal static bool HasCreateRole(AuthorizationRoles currentUserRoles, AyaType objectType)
|
||||||
{
|
{
|
||||||
if (currentUserRoles.HasAnyFlags(BizRoles.GetRoleSet(objectType).Change))
|
var RoleSet = BizRoles.GetRoleSet(objectType);
|
||||||
|
if (RoleSet == null) return false;
|
||||||
|
if (currentUserRoles.HasAnyFlags(RoleSet.Change))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -172,7 +179,9 @@ namespace AyaNova.Api.ControllerHelpers
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
internal static bool HasModifyRole(AuthorizationRoles currentUserRoles, AyaType objectType)
|
internal static bool HasModifyRole(AuthorizationRoles currentUserRoles, AyaType objectType)
|
||||||
{
|
{
|
||||||
if (currentUserRoles.HasAnyFlags(BizRoles.GetRoleSet(objectType).Change))
|
var RoleSet = BizRoles.GetRoleSet(objectType);
|
||||||
|
if (RoleSet == null) return false;
|
||||||
|
if (currentUserRoles.HasAnyFlags(RoleSet.Change))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -204,7 +213,9 @@ namespace AyaNova.Api.ControllerHelpers
|
|||||||
//For now just going to treat as a modify, but for maximum flexibility keeping this as a separate method in case we change our minds in future
|
//For now just going to treat as a modify, but for maximum flexibility keeping this as a separate method in case we change our minds in future
|
||||||
internal static bool HasDeleteRole(AuthorizationRoles currentUserRoles, AyaType objectType)
|
internal static bool HasDeleteRole(AuthorizationRoles currentUserRoles, AyaType objectType)
|
||||||
{
|
{
|
||||||
if (currentUserRoles.HasAnyFlags(BizRoles.GetRoleSet(objectType).Change))
|
var RoleSet = BizRoles.GetRoleSet(objectType);
|
||||||
|
if (RoleSet == null) return false;
|
||||||
|
if (currentUserRoles.HasAnyFlags(RoleSet.Change))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
public async Task<IActionResult> GetList([FromRoute] string enumkey)
|
public async Task<IActionResult> GetList([FromRoute] string enumkey)
|
||||||
{
|
{
|
||||||
if (serverState.IsClosed)
|
if (serverState.IsClosed)
|
||||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||||
var ret = await GetEnumList(enumkey, UserTranslationIdFromContext.Id(HttpContext.Items), UserRolesFromContext.Roles(HttpContext.Items));
|
var ret = await GetEnumList(enumkey, UserTranslationIdFromContext.Id(HttpContext.Items), UserRolesFromContext.Roles(HttpContext.Items));
|
||||||
return Ok(ApiOkResponse.Response(ret));
|
return Ok(ApiOkResponse.Response(ret));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user