fix: #7423 private uploads are linked to login page, for guests

v1.18.x
Julian Lam 6 years ago
parent bd09ba92e5
commit 49e3a368f8

@ -254,9 +254,10 @@ define('forum/topic/posts', [
Posts.showBottomPostBar();
posts.find('[component="post/content"] img:not(.not-responsive)').addClass('img-responsive');
Posts.addBlockquoteEllipses(posts);
hidePostToolsForDeletedPosts(posts);
hidePostToolsForDeletedPosts(posts);
addNecroPostMessage();
handlePrivateUploads(posts);
};
function addNecroPostMessage() {
@ -282,6 +283,27 @@ define('forum/topic/posts', [
});
}
function handlePrivateUploads(posts) {
if (app.user.uid) {
return;
}
// Replace all requests for uploaded images/files with a login link
var loginEl = document.createElement('a');
loginEl.className = 'login-required';
loginEl.href = config.relative_path + '/login';
loginEl.appendChild(document.createTextNode('🔒 Log in to view'));
posts.each(function (idx, postEl) {
$(postEl).find('[component="post/content"] img').each(function (idx, imgEl) {
imgEl = $(imgEl);
if (imgEl.attr('src').startsWith(config.relative_path + config.upload_url)) {
imgEl.replaceWith(loginEl.cloneNode(true));
}
});
});
}
Posts.onNewPostsAddedToDom = function (posts) {
Posts.onTopicPageLoad(posts);

Loading…
Cancel
Save