public async Task <List <BlogInfoStruct> > GetUserBlogs(
            string key,
            string userName,
            string password,
            CancellationToken cancellationToken)
        {
            var result = new List <BlogInfoStruct>();

            //var blog= await projectService.GetProjectSettings(
            //    permissions.BlogId
            //    );
            //if(blog != null)
            //{
            //    var url = await blogService.ResolveBlogUrl(blog).ConfigureAwait(false);
            //    var b = mapper.GetStructFromBlog(blog, url);
            //    result.Add(b);
            //}

            var userBlogs = await projectService.GetUserProjects(userName, password)
                            .ConfigureAwait(false);

            foreach (ProjectSettings blog in userBlogs)
            {
                var url = await blogService.ResolveBlogUrl(blog).ConfigureAwait(false);

                var b = mapper.GetStructFromBlog(blog, url);
                result.Add(b);
            }

            return(result);
        }
Beispiel #2
0
        public async Task <List <BlogInfoStruct> > GetUserBlogs(
            string key,
            string userName,
            string password,
            CancellationToken cancellationToken)
        {
            var result = new List <BlogInfoStruct>();

            var permission = await _security.ValidatePermissions(
                string.Empty,
                userName,
                password,
                CancellationToken.None
                ).ConfigureAwait(false);

            if (!permission.CanEditPosts)
            {
                _log.LogWarning($"user {userName} cannot edit posts");
                return(result); //empty
            }

            var project = await _projectService.GetCurrentProjectSettings();

            if (project == null)
            {
                _log.LogError($"could not resolve project settings");
                return(result); //empty
            }

            var url = await _blogUrlResolver.ResolveBlogUrl(project).ConfigureAwait(false);

            var b = _mapper.GetStructFromBlog(project, url);

            result.Add(b);

            return(result);
        }