Пример #1
0
        public async void Can_Validate_Request()
        {
            Scaffold.Config();

            Guid guid = Guid.NewGuid();

            WorkflowTaskInstancePoco task = Scaffold.Task(guid);

            _tasksService.InsertTask(task);
            _instancesService.InsertInstance(Scaffold.Instance(guid, 1, 1089));

            // is valid when the user is in the group responsible for the task with the given id
            // and the task belongs to the given instance by guid
            // and both the task and instance are related to the given node id
            bool isValid = await _previewService.Validate(1089, 0, task.Id, guid);

            Assert.True(isValid);

            isValid = await _previewService.Validate(1089, 99, 6456, guid);

            Assert.False(isValid);
        }
Пример #2
0
        public async void Can_Validate_Request()
        {
            Guid guid = Guid.NewGuid();

            const int userId = 11;
            const int nodeId = 1089;

            UserGroupPoco group = await AddGroupWithPermissionAndUser(userId, nodeId);

            // create a task on an instance
            WorkflowTaskPoco task = Scaffold.Task(guid, groupId: group.GroupId);

            _tasksService.InsertTask(task);
            _instancesService.InsertInstance(Scaffold.Instance(guid, 1, nodeId));

            // is valid when the user is in the group responsible for the task with the given id
            // and the task belongs to the given instance by guid
            // and both the task and instance are related to the given node id
            bool isValid = await _previewService.Validate(nodeId, userId, task.Id, guid);

            Assert.True(isValid);

            // invalid user id
            isValid = await _previewService.Validate(nodeId, 99, task.Id, guid);

            Assert.False(isValid);

            // invalid task id
            isValid = await _previewService.Validate(nodeId, userId, 11111, guid);

            Assert.False(isValid);

            // invalid guid
            isValid = await _previewService.Validate(nodeId, userId, task.Id, Guid.NewGuid());

            Assert.False(isValid);

            // invalid node id
            isValid = await _previewService.Validate(43535, userId, task.Id, guid);

            Assert.False(isValid);
        }
Пример #3
0
        public ActionResult Index(RenderModel model, int nodeId, int userId, int taskId, Guid guid)
        {
            Utility.ExpireCookie("Workflow_Preview");

            if (_previewService.Validate(nodeId, userId, taskId, guid).Result)
            {
                _previewService.Generate(nodeId, userId, guid);

                Utility.SetCookie(UmbracoConfig.For.UmbracoSettings().Security.AuthCookieName,
                                  HttpContext.Items[UmbracoConfig.For.UmbracoSettings().Security.AuthCookieName] as string, $"/{nodeId}");
            }
            else
            {
                Utility.ExpireCookie(UmbracoConfig.For.UmbracoSettings().Security.AuthCookieName);
                Utility.ExpireCookie(Constants.Web.PreviewCookieName);

                // add a cookie to indicate that the preview request was invalid
                Utility.SetCookie("Workflow_Preview", "0", httpOnly: false);
            }

            return(File("/app_plugins/workflow/backoffice/preview/workflow.preview.html", "text/html"));
        }