internal PWASNavigationNode(PwasObject obj, PwasAction action, PwasScope scope) : base() { this.PwasObject = obj; this.PwasAction = action; this.PwasScope = scope; }
internal static PwasScope IsAuthorized(int userId, PwasObject obj, PwasAction action) { RolePermission permission = Security.RolePermissionsRepo.RolePermissions.Single(rp => rp.roleID == Security.UsersRepo.GetById(userId).roleID&& rp.@object == obj.StringValue()); switch (action) { case PwasAction.View: return((PwasScope)permission.obj_view); case PwasAction.Create: return((PwasScope)permission.obj_create); case PwasAction.Update: return((PwasScope)permission.obj_update); case PwasAction.Delete: return((PwasScope)permission.obj_delete); default: return(PwasScope.None); } }
internal static string StringValue(this PwasObject obj) { switch (obj) { case PwasObject.Order: return("order"); case PwasObject.PrintRun: return("run"); case PwasObject.Role: return("role"); case PwasObject.RolePermission: return("permission"); case PwasObject.User: return("user"); default: return(null); } }
internal static bool IsAuthorized(int userId, PwasObject obj, PwasAction action, PwasScope scope) { PwasScope permissionScope = IsAuthorized(userId, obj, action); return(permissionScope >= scope); }