How to highlight not being logged in

At our company many content can be accessed without being logged in. Unfortunately many users just start to search for any stuff but do not recognize that they re browsing anonymous and therefor not getting all possible results.

Thats why we re thinking about making missing login more obvious, as example change the header to red or add a banner...

Any ideas how to get this running?

Many thanks,
Hans-Hermann

1 answer

1 accepted

0 votes
Answer accepted
AJS.toInit(function() {
	var msg = "booh! log in!";

	var $container;

	// is the messageContainer already visable?
	if($('#messageContainer')[0]) {
		$container = $('#messageContainer')
	} else {
		$container = $('<ul id="messageContainer"></div>')
		    .prependTo('#full-height-container');	
	}

	var $msgContainer = $('<li id="confluence-message-websudo-message" class="confluence-messages noteMessage"></li>')
	    .appendTo($container);

	// if AJS finds no username, the person should be anon
	if(!AJS.params.remoteUser) {
		var $msg = $('<div class="aui-message warning "><span class="aui-icon icon-warning"></span></div>')
		   .appendTo($container);
	   $('<span></span>')
	       .text(msg)
	       .appendTo($msg);
	}

});

This adds a warning banner similar to the one you get when in the admin panel, if there is no username present (e.g anon user)

Hmm, sounds interesting!

But where to put this stuff into? In the "Custom HTML"?

An eariler question indicated that older verisons of confluence does not run javascript when added via the Custom HTML.
I've tested the script on confluence 5.4 by adding the following to one of the custom html boxes. 
<script>
AJS.toInit(function() {
	var msg = "booh! log in!";

	var $container;

	// is the messageContainer already visable?
	if($('#messageContainer')[0]) {
		$container = $('#messageContainer')
	} else {
		$container = $('<ul id="messageContainer"></div>')
		    .prependTo('#full-height-container');	
	}

	var $msgContainer = $('<li id="confluence-message-websudo-message" class="confluence-messages noteMessage"></li>')
	    .appendTo($container);

	// if AJS finds no username, the person should be anon
	if(!AJS.params.remoteUser) {
		var $msg = $('<div class="aui-message warning "><span class="aui-icon icon-warning"></span></div>')
		   .appendTo($container);
	   $('<span></span>')
	       .text(msg)
	       .appendTo($msg);
	}

});
</script>

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 12, 2019 in Confluence

Confluence Admin Certification now $150 for Community Members

More and more people are building their careers with Atlassian, and we want you to be at the front of this wave! Important Dates Start the Certification Prep Course by 2 April 2019 Take your e...

277 views 2 10
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you