Пример #1
0
 internal PWASNavigationNode(PwasObject obj, PwasAction action, PwasScope scope)
     : base()
 {
     this.PwasObject = obj;
     this.PwasAction = action;
     this.PwasScope  = scope;
 }
Пример #2
0
        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);
            }
        }
Пример #3
0
        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);
            }
        }
Пример #4
0
        internal static bool IsAuthorized(int userId, PwasObject obj, PwasAction action, PwasScope scope)
        {
            PwasScope permissionScope = IsAuthorized(userId, obj, action);

            return(permissionScope >= scope);
        }