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

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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jul 10, 2018 in Confluence

We want to see the templates you've created in Confluence!

Hi Community, Jessica here from the Confluence Product Marketing team!  July’s community challenge is all about sharing pictures  — and as an extension of our first post on what ...

866 views 23 12
Join discussion

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