Merge pull request #3464 from sbwalker/dev

fix #3420 - auto create user folder for Host user if it does not exist for site
This commit is contained in:
Shaun Walker 2023-11-10 13:49:31 -05:00 committed by GitHub
commit dead4e3f85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -95,6 +95,33 @@ namespace Oqtane.Controllers
folderPath += "/"; folderPath += "/";
} }
Folder folder = _folders.GetFolder(siteId, folderPath); Folder folder = _folders.GetFolder(siteId, folderPath);
if (folder == null && User.IsInRole(RoleNames.Host) && path.StartsWith("Users/"))
{
// create the user folder on this site for the host user
var userId = int.Parse(path.ReplaceMultiple(new string[] { "Users", "/" }, ""));
folder = _folders.GetFolder(siteId, "Users/");
if (folder != null)
{
folder = _folders.AddFolder(new Folder
{
SiteId = folder.SiteId,
ParentId = folder.FolderId,
Name = "My Folder",
Type = FolderTypes.Private,
Path = path,
Order = 1,
ImageSizes = "",
Capacity = Constants.UserFolderCapacity,
IsSystem = true,
PermissionList = new List<Permission>
{
new Permission(PermissionNames.Browse, userId, true),
new Permission(PermissionNames.View, RoleNames.Everyone, true),
new Permission(PermissionNames.Edit, userId, true)
}
});
}
}
if (folder != null && folder.SiteId == _alias.SiteId && _userPermissions.IsAuthorized(User, PermissionNames.View, folder.PermissionList)) if (folder != null && folder.SiteId == _alias.SiteId && _userPermissions.IsAuthorized(User, PermissionNames.View, folder.PermissionList))
{ {
return folder; return folder;