public ActionResult RemovePermission(string pid, string groupid)
        {
            string userId = this.User.QID();

            if (userId == null)
            {
                return(null);
            }

            QuantApp.Kernel.IPermissible permissible = QuantApp.Kernel.User.FindUser(pid);

            if (permissible == null)
            {
                permissible = QuantApp.Kernel.User.FindUserBySecret(pid);
            }

            if (permissible == null)
            {
                permissible = FileRepository.File(pid);
            }

            QuantApp.Kernel.Group group = QuantApp.Kernel.Group.FindGroup(groupid);
            if (group == null)
            {
                group = QuantApp.Kernel.Group.FindGroup(groupid.Replace("_Workflow", ""));
            }

            if (permissible != null)
            {
                group.Remove(permissible);

                return(Ok(new { Data = "ok" }));
            }
            return(BadRequest(new { Data = "Permissible ID not found" }));
        }
        public ActionResult SetPermission(string pid, string groupid, int accessType, int year = 9999, int month = 12, int day = 31)
        {
            string userId = this.User.QID();

            if (userId == null)
            {
                return(null);
            }

            QuantApp.Kernel.IPermissible permissible = QuantApp.Kernel.User.FindUser(pid);

            if (permissible == null)
            {
                permissible = QuantApp.Kernel.User.FindUserBySecret(pid);
            }

            if (permissible == null)
            {
                permissible = FileRepository.File(pid);
            }

            if (permissible == null)
            {
                return(BadRequest(new { Data = "Permissible ID was not found" }));
            }

            try
            {
                var testAccesss = (AccessType)accessType;
            }
            catch
            {
                return(BadRequest(new { Data = "accessType needs to be an integer between -2 and 2" }));
            }

            QuantApp.Kernel.Group group = QuantApp.Kernel.Group.FindGroup(groupid);
            if (group == null)
            {
                group = QuantApp.Kernel.Group.FindGroup(groupid.Replace("_Workflow", ""));
            }

            if (group == null)
            {
                group = QuantApp.Kernel.Group.CreateGroup(groupid, groupid);
            }

            group.Add(permissible, typeof(QuantApp.Kernel.User), (AccessType)accessType, new DateTime(year, month, day));

            return(Ok(new { Data = "ok" }));
        }
Пример #3
0
        public ActionResult GetPermission(string pid, string groupid)
        {
            string userId = this.User.QID();

            if (userId == null)
            {
                return(null);
            }

            QuantApp.Kernel.IPermissible permissible = QuantApp.Kernel.User.FindUser(pid);
            if (permissible == null)
            {
                permissible = FileRepository.File(pid);
            }

            if (permissible == null)
            {
                return(BadRequest(new { Data = "Permissible ID not found" }));
            }

            QuantApp.Kernel.Group group = QuantApp.Kernel.Group.FindGroup(groupid);
            if (group == null)
            {
                group = QuantApp.Kernel.Group.FindGroup(groupid.Replace("_Workflow", ""));
            }

            if (group == null)
            {
                return(BadRequest(new { Data = "Group ID not found" }));
            }

            if (permissible != null)
            {
                return(Ok(new { Data = group.Permission(null, permissible) }));
            }

            return(Ok(new { Data = AccessType.Denied }));
        }
Пример #4
0
        public ActionResult GetExpiry(string groupid)
        {
            string userId = this.User.QID();

            if (userId == null)
            {
                return(null);
            }

            QuantApp.Kernel.IPermissible permissible = QuantApp.Kernel.User.FindUser(userId);
            QuantApp.Kernel.Group        group       = QuantApp.Kernel.Group.FindGroup(groupid);
            if (group == null)
            {
                group = QuantApp.Kernel.Group.FindGroup(groupid.Replace("_Workflow", ""));
            }

            if (permissible != null && group != null)
            {
                return(Ok(new { Data = group.Expiry(null, permissible) }));
            }

            return(Ok(new { Data = DateTime.MaxValue }));
        }
Пример #5
0
        public ActionResult GetPermission(string groupid)
        {
            string userId = this.User.QID();

            if (userId == null)
            {
                return(null);
            }

            QuantApp.Kernel.IPermissible permissible = QuantApp.Kernel.User.FindUser(userId);
            QuantApp.Kernel.Group        group       = QuantApp.Kernel.Group.FindGroup(groupid);
            if (group == null)
            {
                group = QuantApp.Kernel.Group.FindGroup(groupid.Replace("_Workflow", ""));
            }

            if (permissible != null && group != null)
            {
                return(Ok(new { Data = group.Permission(null, permissible) }));
            }

            return(Ok(new { Data = AccessType.Denied }));
        }