publish those public files found under the first 'pub' subdir

This commit is contained in:
2019-08-22 16:08:54 +01:00
parent ba5e5bad11
commit f1ee5ffde0

View File

@ -24,13 +24,27 @@ namespace Yavsc.Services
// Assert (normalizedFullPath!=null) // Assert (normalizedFullPath!=null)
var parts = normalizedFullPath.Split('/'); var parts = normalizedFullPath.Split('/');
// below 4 parts, no file name.
if (parts.Length<4) return FileAccessRight.None; if (parts.Length<4) return FileAccessRight.None;
var funame = parts[2];
var filePath = string.Join("/",parts.Skip(3)); var filePath = string.Join("/",parts.Skip(3));
_logger.LogInformation($"{normalizedFullPath} from {funame}"); var firstFileNamePart = parts[3];
if (firstFileNamePart == "pub")
{
_logger.LogInformation("Serving public file.");
return FileAccessRight.Read;
}
var funame = parts[2];
_logger.LogInformation($"{normalizedFullPath} from {funame}");
if (funame == user?.GetUserName())
{
_logger.LogInformation("Serving file to owner.");
return FileAccessRight.Read | FileAccessRight.Write;
}
if (funame == user?.GetUserName()) return FileAccessRight.Read | FileAccessRight.Write;
var ucl = user.Claims.Where(c => c.Type == YavscClaimTypes.CircleMembership).Select(c => long.Parse(c.Value)).Distinct().ToArray(); var ucl = user.Claims.Where(c => c.Type == YavscClaimTypes.CircleMembership).Select(c => long.Parse(c.Value)).Distinct().ToArray();