mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-11-03 20:45:58 +01:00 
			
		
		
		
	fix: #7423 private uploads are linked to login page, for guests
This commit is contained in:
		@@ -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);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user