Merge pull request #5033 from sbwalker/dev

fix #5018 - redirect file download to login page
This commit is contained in:
Shaun Walker 2025-01-28 16:31:03 -05:00 committed by GitHub
commit aa9214477c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -122,9 +122,16 @@ namespace Oqtane.Pages
if (file.Folder.SiteId != _alias.SiteId || !_userPermissions.IsAuthorized(User, PermissionNames.View, file.Folder.PermissionList))
{
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized File Access Attempt For Site {SiteId} And Path {Path}", _alias.SiteId, path);
HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;
return BrokenFile();
if (!User.Identity.IsAuthenticated && download)
{
return Redirect(Utilities.NavigateUrl(_alias.Path, "login", "?returnurl=" + WebUtility.UrlEncode(Request.Path)));
}
else
{
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized File Access Attempt For Site {SiteId} And Path {Path}", _alias.SiteId, path);
HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;
return BrokenFile();
}
}
string etag;