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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Apr 13, 2018 in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

2,921 views 27 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