Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Scriptrunner: Show a web panel only for not logged in users

I want to show a web panel with Scriptrunner only to not logged in users and can't find the right condition for this. What I've tried:

if (url.contains('login'))

— works, but is too simple: it doesn't match login forms on the primary dashboard page.

import com.atlassian.jira.component.ComponentAccessor
[…]if (currentUser.key == null)

— doesn't work, never seems to be null. Any ideas?

 

Thanks in avance,

Andreas

 

1 answer

1 accepted

1 vote
Answer accepted
Leonard Chew Community Leader Dec 17, 2019

This should do the job:

import com.atlassian.jira.component.ComponentAccessor

if (!ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser())
{ return true }

This does the trick. Thank you very much!

Like Leonard Chew likes this

Thanks a lot! this works also for "script fragments" - useful for writing a message about login that only not-yet-logged-in users should see.

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you