This commit is contained in:
@@ -1,48 +1,48 @@
|
||||
using AyaNova.Models;
|
||||
using AyaNova.Biz;
|
||||
// using AyaNova.Models;
|
||||
// using AyaNova.Biz;
|
||||
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using System.Reflection;
|
||||
using System;
|
||||
// using Microsoft.EntityFrameworkCore;
|
||||
// using Microsoft.EntityFrameworkCore.Metadata;
|
||||
// using System.Reflection;
|
||||
// using System;
|
||||
|
||||
|
||||
namespace AyaNova.Biz
|
||||
{
|
||||
// namespace AyaNova.Biz
|
||||
// {
|
||||
|
||||
/// <summary>
|
||||
/// Returns owner Id if the object exists or 0 if exists but there is no owner ID property or -1 if the object doesn't exist
|
||||
/// </summary>
|
||||
internal static class AyaObjectOwnerId
|
||||
{
|
||||
internal static long Get(AyaTypeId o, AyContext ct)
|
||||
{
|
||||
if (o.IsEmpty) return -1;
|
||||
// /// <summary>
|
||||
// /// Returns owner Id if the object exists or 0 if exists but there is no owner ID property or -1 if the object doesn't exist
|
||||
// /// </summary>
|
||||
// internal static class AyaObjectOwnerId
|
||||
// {
|
||||
// internal static long Get(AyaTypeId o, AyContext ct)
|
||||
// {
|
||||
// if (o.IsEmpty) return -1;
|
||||
|
||||
|
||||
//Get the type of the model of AyaObject
|
||||
Type t = Type.GetType("AyaNova.Models." + o.ObjectType.ToString());
|
||||
// //Get the type of the model of AyaObject
|
||||
// Type t = Type.GetType("AyaNova.Models." + o.ObjectType.ToString());
|
||||
|
||||
//Run a find query on the db context based on the model's type
|
||||
object record = ct.Find(t, o.ObjectId);
|
||||
if (record == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
// //Run a find query on the db context based on the model's type
|
||||
// object record = ct.Find(t, o.ObjectId);
|
||||
// if (record == null)
|
||||
// {
|
||||
// return -1;
|
||||
// }
|
||||
|
||||
|
||||
PropertyInfo ownerIdPropertyInfo = record.GetType().GetProperty("OwnerId");
|
||||
// PropertyInfo ownerIdPropertyInfo = record.GetType().GetProperty("OwnerId");
|
||||
|
||||
if (ownerIdPropertyInfo == null)
|
||||
return 0;//object exists and it doesn't have an ownerID property
|
||||
// if (ownerIdPropertyInfo == null)
|
||||
// return 0;//object exists and it doesn't have an ownerID property
|
||||
|
||||
|
||||
long ret = (long)ownerIdPropertyInfo.GetValue(record, null);
|
||||
// long ret = (long)ownerIdPropertyInfo.GetValue(record, null);
|
||||
|
||||
return ret;
|
||||
// return ret;
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
}//eons
|
||||
// }//eons
|
||||
|
||||
@@ -71,15 +71,15 @@ namespace AyaNova.Biz
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the ownerId for the object in question
|
||||
/// </summary>
|
||||
/// <param name="ct">db context</param>
|
||||
/// <returns>0 if object doesn't have an owner Id, the owner Id or -1 if the object doesn't exist in the db</returns>
|
||||
public long OwnerId(AyContext ct)
|
||||
{
|
||||
return AyaObjectOwnerId.Get(this, ct);
|
||||
}
|
||||
// /// <summary>
|
||||
// /// Get the ownerId for the object in question
|
||||
// /// </summary>
|
||||
// /// <param name="ct">db context</param>
|
||||
// /// <returns>0 if object doesn't have an owner Id, the owner Id or -1 if the object doesn't exist in the db</returns>
|
||||
// public long OwnerId(AyContext ct)
|
||||
// {
|
||||
// return AyaObjectOwnerId.Get(this, ct);
|
||||
// }
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -6,8 +6,7 @@ namespace AyaNova.Biz
|
||||
/// </summary>
|
||||
public class BizRoleSet
|
||||
{
|
||||
public AuthorizationRoles Change { get; set; }
|
||||
public AuthorizationRoles EditOwn { get; set; }
|
||||
public AuthorizationRoles Change { get; set; }
|
||||
public AuthorizationRoles ReadFullRecord { get; set; }
|
||||
|
||||
}//eoc
|
||||
|
||||
@@ -36,8 +36,7 @@ namespace AyaNova.Biz
|
||||
//
|
||||
roles.Add(AyaType.User, new BizRoleSet()
|
||||
{
|
||||
Change = AuthorizationRoles.BizAdminFull,
|
||||
EditOwn = AuthorizationRoles.NoRole,//no one can make a user but a bizadminfull
|
||||
Change = AuthorizationRoles.BizAdminFull,
|
||||
ReadFullRecord = AuthorizationRoles.BizAdminLimited
|
||||
});
|
||||
|
||||
@@ -48,7 +47,6 @@ namespace AyaNova.Biz
|
||||
roles.Add(AyaType.UserOptions, new BizRoleSet()
|
||||
{
|
||||
Change = AuthorizationRoles.BizAdminFull,
|
||||
EditOwn = AuthorizationRoles.NoRole,//no one can make a user but a bizadminfull
|
||||
ReadFullRecord = AuthorizationRoles.BizAdminLimited
|
||||
});
|
||||
|
||||
@@ -60,7 +58,6 @@ namespace AyaNova.Biz
|
||||
roles.Add(AyaType.Widget, new BizRoleSet()
|
||||
{
|
||||
Change = AuthorizationRoles.BizAdminFull | AuthorizationRoles.InventoryFull,
|
||||
EditOwn = AuthorizationRoles.TechFull,
|
||||
ReadFullRecord = AuthorizationRoles.BizAdminLimited | AuthorizationRoles.InventoryLimited
|
||||
});
|
||||
|
||||
@@ -70,7 +67,6 @@ namespace AyaNova.Biz
|
||||
roles.Add(AyaType.ServerState, new BizRoleSet()
|
||||
{
|
||||
Change = AuthorizationRoles.OpsAdminFull,
|
||||
EditOwn = AuthorizationRoles.NoRole,
|
||||
ReadFullRecord = AuthorizationRoles.AnyRole
|
||||
});
|
||||
|
||||
@@ -81,7 +77,6 @@ namespace AyaNova.Biz
|
||||
roles.Add(AyaType.License, new BizRoleSet()
|
||||
{
|
||||
Change = AuthorizationRoles.BizAdminFull | AuthorizationRoles.OpsAdminFull,
|
||||
EditOwn = AuthorizationRoles.NoRole,
|
||||
ReadFullRecord = AuthorizationRoles.BizAdminLimited | AuthorizationRoles.OpsAdminLimited
|
||||
});
|
||||
|
||||
@@ -91,7 +86,6 @@ namespace AyaNova.Biz
|
||||
roles.Add(AyaType.LogFile, new BizRoleSet()
|
||||
{
|
||||
Change = AuthorizationRoles.NoRole,
|
||||
EditOwn = AuthorizationRoles.NoRole,
|
||||
ReadFullRecord = AuthorizationRoles.OpsAdminFull | AuthorizationRoles.OpsAdminLimited
|
||||
});
|
||||
|
||||
@@ -105,7 +99,6 @@ namespace AyaNova.Biz
|
||||
roles.Add(AyaType.JobOperations, new BizRoleSet()
|
||||
{
|
||||
Change = AuthorizationRoles.OpsAdminFull,
|
||||
EditOwn = AuthorizationRoles.NoRole,
|
||||
ReadFullRecord = AuthorizationRoles.OpsAdminLimited | AuthorizationRoles.BizAdminFull | AuthorizationRoles.BizAdminLimited
|
||||
});
|
||||
|
||||
@@ -115,7 +108,6 @@ namespace AyaNova.Biz
|
||||
roles.Add(AyaType.AyaNova7Import, new BizRoleSet()
|
||||
{
|
||||
Change = AuthorizationRoles.OpsAdminFull,
|
||||
EditOwn = AuthorizationRoles.NoRole,
|
||||
ReadFullRecord = AuthorizationRoles.NoRole
|
||||
});
|
||||
|
||||
@@ -126,7 +118,6 @@ namespace AyaNova.Biz
|
||||
roles.Add(AyaType.Metrics, new BizRoleSet()
|
||||
{
|
||||
Change = AuthorizationRoles.NoRole,
|
||||
EditOwn = AuthorizationRoles.NoRole,
|
||||
ReadFullRecord = AuthorizationRoles.OpsAdminFull | AuthorizationRoles.OpsAdminLimited
|
||||
});
|
||||
|
||||
@@ -137,7 +128,6 @@ namespace AyaNova.Biz
|
||||
roles.Add(AyaType.Locale, new BizRoleSet()
|
||||
{
|
||||
Change = AuthorizationRoles.BizAdminFull | AuthorizationRoles.OpsAdminFull,
|
||||
EditOwn = AuthorizationRoles.NoRole,
|
||||
ReadFullRecord = AuthorizationRoles.AnyRole
|
||||
});
|
||||
|
||||
@@ -148,7 +138,6 @@ namespace AyaNova.Biz
|
||||
roles.Add(AyaType.DataFilter, new BizRoleSet()
|
||||
{
|
||||
Change = AuthorizationRoles.BizAdminFull,
|
||||
EditOwn = AuthorizationRoles.AnyRole,
|
||||
ReadFullRecord = AuthorizationRoles.AnyRole
|
||||
});
|
||||
|
||||
@@ -159,7 +148,6 @@ namespace AyaNova.Biz
|
||||
{
|
||||
//Only BizAdminFull can modify forms
|
||||
Change = AuthorizationRoles.BizAdminFull,
|
||||
EditOwn = AuthorizationRoles.NoRole,
|
||||
ReadFullRecord = AuthorizationRoles.AnyRole
|
||||
});
|
||||
|
||||
|
||||
@@ -313,7 +313,7 @@ namespace AyaNova.Biz
|
||||
List<AyaTypeId> CanReadMatchingObjects = new List<AyaTypeId>();
|
||||
foreach (AyaTypeId t in MatchingObjects)
|
||||
{
|
||||
if (AyaNova.Api.ControllerHelpers.Authorized.IsAuthorizedToReadFullRecord(currentUserRoles, t.ObjectType))
|
||||
if (AyaNova.Api.ControllerHelpers.Authorized.HasReadFullRole(currentUserRoles, t.ObjectType))
|
||||
{
|
||||
CanReadMatchingObjects.Add(t);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user